import avec project.
[auf_rh_dae.git] / project / dae / permissions.py
CommitLineData
c3f0b49f
EMS
1from auf.django.permissions import allow
2
75f0e87b
DB
3import project.dae.models as dae
4from project.dae.workflow import grp_drh, grp_drh2, grp_haute_direction
5from project.dae.decorators import user_in_dae_groupes
c3f0b49f
EMS
6
7def user_in_group(*groups):
8 def test(user, obj):
9 user_groups = set(user.groups.all())
10 return any(g in user_groups for g in groups)
11 return test
12
13allow('modifier_dae_numerisee', dae.Dossier, user_in_group(grp_drh, grp_drh2, grp_haute_direction))
14
15allow('consulter', dae.Dossier,
16 lambda user, obj: (user_in_dae_groupes(user) or
17 dae.Dossier.objects.ma_region_ou_service(user).filter(id=obj.id).exists()))