DRH peut modifier le précédent titulaire
[auf_rh_dae.git] / project / dae / templatetags / dae.py
CommitLineData
5579d48d 1from django import template
286d0aa9 2from project.dae.workflow import ETATS_EDITABLE
d8cfc3d5 3from project.dae.workflow import grp_correspondants_rh, grp_administrateurs, grp_drh
5579d48d
OL
4
5register = template.Library()
6
7@register.filter
3a62d4fe
OL
8def test_membre_drh(user):
9 return grp_drh in user.groups.all()
10
11@register.filter
5579d48d
OL
12def peut_ajouter(user):
13 for g in user.groups.all():
d8cfc3d5 14 if g in (grp_administrateurs, grp_correspondants_rh, grp_drh):
5579d48d
OL
15 return True
16 return False
17
286d0aa9 18@register.filter
e7ee680f
OL
19def est_editable(obj, user):
20 klass = obj.__class__
21 groupes_users = user.groups.all()
22 if (obj.etat in ETATS_EDITABLE and obj in klass.objects.mes_choses_a_faire(user).all()) or grp_drh in groupes_users:
286d0aa9
OL
23 return True
24 else:
25 return False
26