fix PJ
[auf_rh_dae.git] / project / dae / permissions.py
1 from auf.django.permissions import allow
2
3 import dae.models as dae
4 from dae.workflow import grp_drh, grp_drh2, grp_haute_direction
5 from dae.decorators import user_in_dae_groupes
6
7 def 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
13 allow('modifier_dae_numerisee', dae.Dossier, user_in_group(grp_drh, grp_drh2, grp_haute_direction))
14
15 allow('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()))