DRH peut modifier le précédent titulaire
[auf_rh_dae.git] / project / dae / templatetags / dae.py
1 from django import template
2 from project.dae.workflow import ETATS_EDITABLE
3 from project.dae.workflow import grp_correspondants_rh, grp_administrateurs, grp_drh
4
5 register = template.Library()
6
7 @register.filter
8 def test_membre_drh(user):
9 return grp_drh in user.groups.all()
10
11 @register.filter
12 def peut_ajouter(user):
13 for g in user.groups.all():
14 if g in (grp_administrateurs, grp_correspondants_rh, grp_drh):
15 return True
16 return False
17
18 @register.filter
19 def 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:
23 return True
24 else:
25 return False
26