Modify ↓
Opened 15 years ago
Closed 15 years ago
#5643 closed defect (fixed)
Ticket changes should include comment in them
Reported by: | Owned by: | Mikhail Gusarov | |
---|---|---|---|
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)
Note: See
TracTickets for help on using
tickets.
Committed (in modified form) in r6350.