Commit | Line | Data |
---|---|---|
0b2edb6e OL |
1 | # -*- encoding: utf-8 -*- |
2 | ||
5579d48d | 3 | from django import template |
286d0aa9 | 4 | from project.dae.workflow import ETATS_EDITABLE |
d8cfc3d5 | 5 | from project.dae.workflow import grp_correspondants_rh, grp_administrateurs, grp_drh |
5579d48d OL |
6 | |
7 | register = template.Library() | |
8 | ||
9 | @register.filter | |
3a62d4fe OL |
10 | def test_membre_drh(user): |
11 | return grp_drh in user.groups.all() | |
12 | ||
13 | @register.filter | |
5579d48d OL |
14 | def peut_ajouter(user): |
15 | for g in user.groups.all(): | |
d8cfc3d5 | 16 | if g in (grp_administrateurs, grp_correspondants_rh, grp_drh): |
5579d48d OL |
17 | return True |
18 | return False | |
19 | ||
286d0aa9 | 20 | @register.filter |
e7ee680f OL |
21 | def est_editable(obj, user): |
22 | klass = obj.__class__ | |
23 | groupes_users = user.groups.all() | |
c511cd1f EMS |
24 | if obj.etat in ETATS_EDITABLE and \ |
25 | (obj in klass.objects.mes_choses_a_faire(user).all() or grp_drh in groupes_users): | |
286d0aa9 OL |
26 | return True |
27 | else: | |
28 | return False | |
29 | ||
0b2edb6e OL |
30 | @register.filter |
31 | def region_ou_service(implantation): | |
32 | if implantation.id == 15: | |
33 | return u"Services centraux de Montréal (SCM)" | |
34 | if implantation.id == 19: | |
35 | return u"Services centraux de Paris (SCP)" | |
36 | return implantation.region |