Skip to contentSkip to conversation

views : add check for superusers in layer update notifications

PATCH New Diana Thayer 1 participant 1 message Aug 25, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 views : add check for superusers in layer update notifications

When a user submits a layer, notification emails are sent to users with a certain permission. Superusers technically have all permissions, but Q ignores them currently so that such emails are not sent to superusers. This patch expands the check to include superusers.

A few folks have discussed including this so I put this patch up for consideration.

---
 layerindex/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
layerindex/views.py +1 -1
index 1661cb3..c1a624c 100644
@@ -163,7 +163,7 @@ def edit_layer_view(request, template_name, branch='master', slug=None):
                     # Send email
                     plaintext = get_template('layerindex/submitemail.txt')
                     perm = Permission.objects.get(codename='publish_layer')
-                    users = User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) ).distinct()
+                    users = User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) | Q(is_superuser=True) ).distinct()
                     for user in users:
                         if user.first_name:
                             user_name = user.first_name
Signature · 1 line
2.7.4