Only do the update routine when the status changes for group_app's and role requests.
authorLennard de Rijk <ljvderijk@gmail.com>
Tue, 03 Feb 2009 08:33:46 +0000
changeset 1196 11dbdf12d7c2
parent 1195 cbef45d75942
child 1197 7785b5091f07
Only do the update routine when the status changes for group_app's and role requests. This helps prevent spamming multiple notifications. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/views/models/group_app.py
app/soc/views/models/role.py
--- a/app/soc/views/models/group_app.py	Tue Feb 03 08:25:47 2009 +0000
+++ b/app/soc/views/models/group_app.py	Tue Feb 03 08:33:46 2009 +0000
@@ -257,13 +257,16 @@
 
       if status_value in ['accepted', 'rejected', 'ignored']:
         # this application has been properly reviewed update the status
-        fields = {'status' : status_value}
 
-        self._logic.updateEntityProperties(entity, fields)
+        # only update if the status changes
+        if entity.status != status_value:
+          fields = {'status' : status_value}
 
-        if status_value == 'accepted':
-          # the application has been accepted send out a notification
-          notifications.sendNewGroupNotification(entity, params)
+          self._logic.updateEntityProperties(entity, fields)
+
+          if status_value == 'accepted':
+            # the application has been accepted send out a notification
+            notifications.sendNewGroupNotification(entity, params)
 
         return self.reviewOverview(request, access_type,
             page_name=page_name, params=params, **kwargs)
--- a/app/soc/views/models/role.py	Tue Feb 03 08:25:47 2009 +0000
+++ b/app/soc/views/models/role.py	Tue Feb 03 08:33:46 2009 +0000
@@ -561,11 +561,14 @@
       if get_dict['status'] in ['group_accepted', 'rejected', 'ignored']:
         # update the request_entity and redirect away from this page
         request_status = get_dict['status']
-        request_logic.logic.updateEntityProperties(request_entity, {
-            'status': get_dict['status']})
 
-        if request_status == 'group_accepted':
-          notifications_helper.sendInviteNotification(request_entity)
+        # only update when the status is changing
+        if request_status != request_entity.status:
+          request_logic.logic.updateEntityProperties(request_entity, {
+              'status': get_dict['status']})
+
+          if request_status == 'group_accepted':
+            notifications_helper.sendInviteNotification(request_entity)
 
         group_view = params.get('group_view')
         if not group_view: