Utilisé l'héritage de modèles entre Chercheur et Personne
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / context_processors.py
CommitLineData
9af73c99
AJ
1# -*- encoding: utf-8 -*-
2
bae03b7b 3import re
13ec4813 4from chercheurs.models import Chercheur
9af73c99
AJ
5
6def user_chercheur(request):
7 user_chercheur = Chercheur.objects.none()
8 if request.user.is_authenticated():
9 try:
13ec4813 10 user_chercheur = Chercheur.objects.get(courriel=request.user.email)
9af73c99
AJ
11 except:
12 pass
13ec4813 13 return {'user_chercheur': user_chercheur}
bae03b7b
EMS
14
15DISCIPLINE_REGION_RE = re.compile(r'/(discipline/(?P<discipline>\d+)/)?(region/(?P<region>\d+)/)?')
16def discipline_region(request):
17 match = DISCIPLINE_REGION_RE.match(request.path)
18 discipline = match.group('discipline')
19 region = match.group('region')
20 discipline = discipline and int(discipline)
21 region = region and int(region)
22 return dict(discipline_active=discipline, region_active=region)