Utilisé l'héritage de modèles entre Chercheur et Personne
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / context_processors.py
1 # -*- encoding: utf-8 -*-
2
3 import re
4 from chercheurs.models import Chercheur
5
6 def user_chercheur(request):
7 user_chercheur = Chercheur.objects.none()
8 if request.user.is_authenticated():
9 try:
10 user_chercheur = Chercheur.objects.get(courriel=request.user.email)
11 except:
12 pass
13 return {'user_chercheur': user_chercheur}
14
15 DISCIPLINE_REGION_RE = re.compile(r'/(discipline/(?P<discipline>\d+)/)?(region/(?P<region>\d+)/)?')
16 def 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)