summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2017-05-31 15:45:32 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2017-05-31 17:51:11 (GMT)
commit416fc86434c57bb997e15a2d1a842ee208a75408 (patch)
tree367c1d6e14182c533aceb0c11076995d284e5048
parentb0f33b02ce7532ab1bddf734d3e63c5597afb5a4 (diff)
downloadwelco-416fc86434c57bb997e15a2d1a842ee208a75408.zip
welco-416fc86434c57bb997e15a2d1a842ee208a75408.tar.gz
welco-416fc86434c57bb997e15a2d1a842ee208a75408.tar.bz2
alfortville: also consider DGD* as DGA (#16644)v0.46
-rw-r--r--welco/contrib/alfortville/views.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/welco/contrib/alfortville/views.py b/welco/contrib/alfortville/views.py
index 892988a..1b08133 100644
--- a/welco/contrib/alfortville/views.py
+++ b/welco/contrib/alfortville/views.py
@@ -73,6 +73,11 @@ class Dgs(DgHomeScreen):
dgs = login_required(Dgs.as_view())
+def is_dga_role(role_name):
+ return bool(role_name.startswith('DGA') or role_name.startswith('DGD') or
+ role_name.startswith('Cabinet'))
+
+
class DgaMailHome(MailHome):
display_filter = True
allow_reject = False
@@ -80,7 +85,7 @@ class DgaMailHome(MailHome):
def filter_formdef_condition(self, formdef):
roles = set()
for function_role in formdef.get('functions', {}).values():
- if function_role.get('role', {}).get('name', '').startswith('DGA'):
+ if is_dga_role(function_role.get('role', {}).get('name', '')):
roles.add(function_role.get('role').get('slug'))
return self.user_roles.intersection(roles)
@@ -100,7 +105,7 @@ class Dga(DgHomeScreen):
def check_user_ok(self):
user_roles = [x.name for x in self.request.user.groups.all()]
- return any([x for x in user_roles if x.startswith('DGA') or x.startswith('Cabinet')])
+ return any([x for x in user_roles if is_dga_role(x)])
dga = login_required(Dga.as_view())