Show More
@@ -67,7 +67,7 b' class ChangesetCommentsModel(BaseModel):' | |||||
67 | repo = Repository.get(repo_id) |
|
67 | repo = Repository.get(repo_id) | |
68 | cs = repo.scm_instance.get_changeset(revision) |
|
68 | cs = repo.scm_instance.get_changeset(revision) | |
69 | desc = cs.message |
|
69 | desc = cs.message | |
70 | author = cs.author_email |
|
70 | author_email = cs.author_email | |
71 | comment = ChangesetComment() |
|
71 | comment = ChangesetComment() | |
72 | comment.repo = repo |
|
72 | comment.repo = repo | |
73 | comment.user_id = user_id |
|
73 | comment.user_id = user_id | |
@@ -96,8 +96,8 b' class ChangesetCommentsModel(BaseModel):' | |||||
96 | # get the current participants of this changeset |
|
96 | # get the current participants of this changeset | |
97 | recipients = ChangesetComment.get_users(revision=revision) |
|
97 | recipients = ChangesetComment.get_users(revision=revision) | |
98 |
|
98 | |||
99 | # add changeset author |
|
99 | # add changeset author if it's in rhodecode system | |
100 | recipients += [User.get_by_email(author)] |
|
100 | recipients += [User.get_by_email(author_email)] | |
101 |
|
101 | |||
102 | NotificationModel().create( |
|
102 | NotificationModel().create( | |
103 | created_by=user_id, subject=subj, body=body, |
|
103 | created_by=user_id, subject=subj, body=body, |
@@ -169,10 +169,12 b' class NotificationModel(BaseModel):' | |||||
169 | of notification object |
|
169 | of notification object | |
170 | """ |
|
170 | """ | |
171 |
|
171 | |||
172 | _map = {notification.TYPE_CHANGESET_COMMENT:_('commented on commit'), |
|
172 | _map = { | |
173 |
|
|
173 | notification.TYPE_CHANGESET_COMMENT: _('commented on commit'), | |
174 |
|
|
174 | notification.TYPE_MESSAGE: _('sent message'), | |
175 |
|
|
175 | notification.TYPE_MENTION: _('mentioned you'), | |
|
176 | notification.TYPE_REGISTRATION: _('registered in RhodeCode') | |||
|
177 | } | |||
176 |
|
178 | |||
177 | DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" |
|
179 | DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" | |
178 |
|
180 | |||
@@ -182,9 +184,10 b' class NotificationModel(BaseModel):' | |||||
182 | else: |
|
184 | else: | |
183 | DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT) |
|
185 | DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT) | |
184 | when = DTF(notification.created_on) |
|
186 | when = DTF(notification.created_on) | |
185 | data = dict(user=notification.created_by_user.username, |
|
187 | data = dict( | |
186 | action=_map[notification.type_], |
|
188 | user=notification.created_by_user.username, | |
187 | when=when) |
|
189 | action=_map[notification.type_], when=when, | |
|
190 | ) | |||
188 | return tmpl % data |
|
191 | return tmpl % data | |
189 |
|
192 | |||
190 |
|
193 | |||
@@ -200,10 +203,10 b' class EmailNotificationModel(BaseModel):' | |||||
200 | self._tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup |
|
203 | self._tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup | |
201 |
|
204 | |||
202 | self.email_types = { |
|
205 | self.email_types = { | |
203 |
|
|
206 | self.TYPE_CHANGESET_COMMENT: 'email_templates/changeset_comment.html', | |
204 |
|
|
207 | self.TYPE_PASSWORD_RESET: 'email_templates/password_reset.html', | |
205 |
|
|
208 | self.TYPE_REGISTRATION: 'email_templates/registration.html', | |
206 |
|
|
209 | self.TYPE_DEFAULT: 'email_templates/default.html' | |
207 | } |
|
210 | } | |
208 |
|
211 | |||
209 | def get_email_tmpl(self, type_, **kwargs): |
|
212 | def get_email_tmpl(self, type_, **kwargs): | |
@@ -216,7 +219,7 b' class EmailNotificationModel(BaseModel):' | |||||
216 | base = self.email_types.get(type_, self.email_types[self.TYPE_DEFAULT]) |
|
219 | base = self.email_types.get(type_, self.email_types[self.TYPE_DEFAULT]) | |
217 | email_template = self._tmpl_lookup.get_template(base) |
|
220 | email_template = self._tmpl_lookup.get_template(base) | |
218 | # translator inject |
|
221 | # translator inject | |
219 | _kwargs = {'_':_} |
|
222 | _kwargs = {'_': _} | |
220 | _kwargs.update(kwargs) |
|
223 | _kwargs.update(kwargs) | |
221 | log.debug('rendering tmpl %s with kwargs %s' % (base, _kwargs)) |
|
224 | log.debug('rendering tmpl %s with kwargs %s' % (base, _kwargs)) | |
222 | return email_template.render(**_kwargs) |
|
225 | return email_template.render(**_kwargs) |
General Comments 0
You need to be logged in to leave comments.
Login now