alfortville: also consider DGD* as DGA (#16644)

This commit is contained in:
Frédéric Péters 2017-05-31 17:45:32 +02:00
parent b0f33b02ce
commit 416fc86434
1 changed files with 7 additions and 2 deletions

View File

@ -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())