changeset 2077:179604334d98 beta

code garden
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 01 Mar 2012 00:30:41 +0200
parents 77d215d6121f
children d4b6c8541bd9
files rhodecode/model/comment.py rhodecode/model/notification.py
diffstat 2 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/model/comment.py	Wed Feb 29 23:16:20 2012 +0200
+++ b/rhodecode/model/comment.py	Thu Mar 01 00:30:41 2012 +0200
@@ -92,22 +92,27 @@
                                    )
                              )
             body = text
+
+            # get the current participants of this changeset
             recipients = ChangesetComment.get_users(revision=revision)
+
             # add changeset author
             recipients += [User.get_by_email(author)]
 
-            NotificationModel().create(created_by=user_id, subject=subj,
-                                   body=body, recipients=recipients,
-                                   type_=Notification.TYPE_CHANGESET_COMMENT)
+            NotificationModel().create(
+              created_by=user_id, subject=subj, body=body,
+              recipients=recipients, type_=Notification.TYPE_CHANGESET_COMMENT
+            )
 
             mention_recipients = set(self._extract_mentions(body))\
                                     .difference(recipients)
             if mention_recipients:
                 subj = _('[Mention]') + ' ' + subj
-                NotificationModel().create(created_by=user_id, subject=subj,
-                                    body=body,
-                                    recipients=mention_recipients,
-                                    type_=Notification.TYPE_CHANGESET_COMMENT)
+                NotificationModel().create(
+                    created_by=user_id, subject=subj, body=body,
+                    recipients=mention_recipients,
+                    type_=Notification.TYPE_CHANGESET_COMMENT
+                )
 
             return comment
 
--- a/rhodecode/model/notification.py	Wed Feb 29 23:16:20 2012 +0200
+++ b/rhodecode/model/notification.py	Thu Mar 01 00:30:41 2012 +0200
@@ -85,13 +85,19 @@
                 if obj:
                     recipients_objs.append(obj)
             recipients_objs = set(recipients_objs)
+            log.debug('sending notifications %s to %s' % (
+                type_, recipients_objs)
+            )
         else:
             # empty recipients means to all admins
             recipients_objs = User.query().filter(User.admin == True).all()
-
-        notif = Notification.create(created_by=created_by_obj, subject=subject,
-                                    body=body, recipients=recipients_objs,
-                                    type_=type_)
+            log.debug('sending notifications %s to admins: %s' % (
+                type_, recipients_objs)
+            )
+        notif = Notification.create(
+            created_by=created_by_obj, subject=subject,
+            body=body, recipients=recipients_objs, type_=type_
+        )
 
         if with_email is False:
             return notif