summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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())