comparison rhodecode/model/comment.py @ 2178:989c137f26eb beta

Notification fixes - added cs ID to notification on changeset comment - trimmed long commits to 256 chars - cast to unicode the link re ticket #418
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 01 Apr 2012 01:43:40 +0300
parents a8c9c0094ddf
children b61e540122f2
comparison
equal deleted inserted replaced
2177:ee07357d9265 2178:989c137f26eb
27 import traceback 27 import traceback
28 28
29 from pylons.i18n.translation import _ 29 from pylons.i18n.translation import _
30 from sqlalchemy.util.compat import defaultdict 30 from sqlalchemy.util.compat import defaultdict
31 31
32 from rhodecode.lib.utils2 import extract_mentioned_users 32 from rhodecode.lib.utils2 import extract_mentioned_users, safe_unicode
33 from rhodecode.lib import helpers as h 33 from rhodecode.lib import helpers as h
34 from rhodecode.model import BaseModel 34 from rhodecode.model import BaseModel
35 from rhodecode.model.db import ChangesetComment, User, Repository, Notification 35 from rhodecode.model.db import ChangesetComment, User, Repository, Notification
36 from rhodecode.model.notification import NotificationModel 36 from rhodecode.model.notification import NotificationModel
37 37
65 """ 65 """
66 66
67 if text: 67 if text:
68 repo = Repository.get(repo_id) 68 repo = Repository.get(repo_id)
69 cs = repo.scm_instance.get_changeset(revision) 69 cs = repo.scm_instance.get_changeset(revision)
70 desc = cs.message 70 desc = "%s - %s" % (cs.short_id, h.shorter(cs.message, 256))
71 author_email = cs.author_email 71 author_email = cs.author_email
72 comment = ChangesetComment() 72 comment = ChangesetComment()
73 comment.repo = repo 73 comment.repo = repo
74 comment.user_id = user_id 74 comment.user_id = user_id
75 comment.revision = revision 75 comment.revision = revision
81 self.sa.flush() 81 self.sa.flush()
82 # make notification 82 # make notification
83 line = '' 83 line = ''
84 if line_no: 84 if line_no:
85 line = _('on line %s') % line_no 85 line = _('on line %s') % line_no
86 subj = h.link_to('Re commit: %(commit_desc)s %(line)s' % \ 86 subj = safe_unicode(
87 {'commit_desc': desc, 'line': line}, 87 h.link_to('Re commit: %(commit_desc)s %(line)s' % \
88 h.url('changeset_home', repo_name=repo.repo_name, 88 {'commit_desc': desc, 'line': line},
89 revision=revision, 89 h.url('changeset_home', repo_name=repo.repo_name,
90 anchor='comment-%s' % comment.comment_id, 90 revision=revision,
91 qualified=True, 91 anchor='comment-%s' % comment.comment_id,
92 ) 92 qualified=True,
93 ) 93 )
94 )
95 )
96
94 body = text 97 body = text
95 98
96 # get the current participants of this changeset 99 # get the current participants of this changeset
97 recipients = ChangesetComment.get_users(revision=revision) 100 recipients = ChangesetComment.get_users(revision=revision)
98 101