Modify

Opened 5 years ago

Closed 5 years ago

#5643 closed defect (fixed)

Ticket changes should include comment in them

Reported by: dimitris@… Owned by: dottedmag
Priority: normal Component: TracCiaPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

It's nice to have ticket comments embedded in the "ticket modification" notification.

Here's a patch to do this. It collapses whitespaces and trims the comment to the first 150 characters.

--- traccia/__init__.py	(revision 6347)
+++ traccia/__init__.py	(working copy)
@@ -72,6 +72,16 @@
 def esc(s):
     return saxutils.escape(s)
 
+def smart_truncate(content, length=100, suffix='...'):
+    """Smart string truncate with ellipsis.
+
+    Source: http://stackoverflow.com/questions/250357/smart-truncate-in-python/250373#250373
+    """
+    if len(content) <= length:
+        return content
+    else:
+        return ' '.join(content[:length+1].split(' ')[0:-1]) + suffix
+
 class CiaNotificationComponent(Component):
     implements(IWikiChangeListener)
     implements(IAttachmentChangeListener)
@@ -236,6 +246,10 @@
                 if log: log += '; '
                 log += "changed " + ', '.join(changes)
             log += ' (' + t_url + ')'
+            comment = kwargs.get('comment', None)
+            if comment:
+                comment_stripped = ' '.join(comment.split())
+                log += ': ' + esc(smart_truncate(comment_stripped, 150))
             args['url'] = t_url
             args['log'] = esc(log)
         else:

I believe the same collapsing and truncating could happen to the point where a comment is embedded in a Wiki change notification.

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by dottedmag

  • Resolution set to fixed
  • Status changed from new to closed

Committed (in modified form) in r6350.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from dottedmag. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.