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