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
--- 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: