| 1 | # -*- encoding: utf-8 -*- |
| 2 | |
| 3 | from django.core.exceptions import ObjectDoesNotExist |
| 4 | |
| 5 | CORRESPONDANT_RH = 'Correspondants RH' |
| 6 | ADMINISTRATEURS = 'Administrateurs' |
| 7 | DIRECTEUR_DE_BUREAU = 'Directeurs de bureau' |
| 8 | DRH_NIVEAU_1 = 'DRH' |
| 9 | DRH_NIVEAU_2 = 'DRH-2' |
| 10 | ACCIOR = 'ACCIOR' |
| 11 | ABF = 'ABF' |
| 12 | FINANCE = 'Finance' |
| 13 | HAUTE_DIRECTION = 'Haute direction' |
| 14 | SERVICE_UTILISATEURS = 'Service utilisateurs' |
| 15 | |
| 16 | |
| 17 | def get_employe_from_user(user): |
| 18 | """ |
| 19 | Retourne un employé AUF à partir de son user Django. |
| 20 | """ |
| 21 | import auf.django.references.models as ref |
| 22 | try: |
| 23 | employe = ref.Employe.objects.get(courriel=user.email) |
| 24 | except ObjectDoesNotExist: |
| 25 | raise Exception(u"L'employé avec le courriel %s n'a pas \ |
| 26 | été trouvé dans le référentiel." % user.email) |
| 27 | return employe |
| 28 | |
| 29 | |
| 30 | def is_user_dans_services_centraux(user): |
| 31 | employe = get_employe_from_user(user) |
| 32 | if employe.id == 2190: # rola saade gère les DAE des Amériques |
| 33 | return False |
| 34 | return employe.implantation_id in (15, 19) |
| 35 | |
| 36 | |
| 37 | def is_user_dans_region(user): |
| 38 | return not is_user_dans_services_centraux(user) |