Commit | Line | Data |
---|---|---|
5633fa41 OL |
1 | # -*- encoding: utf-8 -*- |
2 | ||
bf6f2712 | 3 | import auf.django.references.models as ref |
5633fa41 OL |
4 | |
5 | def get_employe_from_user(user): | |
6 | """ | |
7 | Retourne un employé AUF à partir de son user Django. | |
8 | """ | |
9 | try: | |
10 | employe = ref.Authentification.objects.get(courriel=user.email).id | |
11 | except: | |
12 | raise Exception(u"L'employé avec le courriel %s n'a pas été trouvé dans le référentiel." % user.email) | |
13 | return employe | |
14 | ||
d8cfc3d5 | 15 | def is_user_dans_services_centraux(user): |
5633fa41 | 16 | employe = get_employe_from_user(user) |
e622b59c OL |
17 | if employe.id == 12: # monique chéry gère les DAE des amériques |
18 | return False | |
3420143c | 19 | return employe.implantation_id in (15, 19) |
5633fa41 OL |
20 | |
21 | def is_user_dans_region(user): | |
22 | employe = get_employe_from_user(user) | |
42dfa870 | 23 | return not is_user_dans_services_centraux(user) |
5633fa41 OL |
24 | |
25 |