nb chercheurs
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / chercheurs / views.py
1 # -*- encoding: utf-8 -*-
2 from django.shortcuts import render_to_response
3 from django.template import Context, RequestContext
4 from forms import *
5
6 from auf_references_client.models import Discipline, TypeImplantation
7 from models import Personne
8
9 def repertoire(request):
10 """Mock up du répertoire"""
11 chercheurs = Chercheur.objects.all()
12 nb_chercheurs = chercheurs.count()
13 variables = { 'chercheurs': chercheurs,
14 'nb_chercheurs': nb_chercheurs,
15 }
16 return render_to_response ("chercheurs/repertoire.html", \
17 Context (variables),
18 context_instance = RequestContext(request))
19
20 def inscription(request):
21 if request.method == 'POST':
22 personne_form = PersonneForm (request.POST, prefix="personne")
23 chercheur_form = ChercheurForm (request.POST, prefix="chercheur")
24 if personne_form.is_valid():
25 if chercheur_form.is_valid():
26 p = personne_form.save()
27 c = chercheur_form.save(commit=False)
28 c.personne = p
29 c.save()
30 else:
31 personne_form = PersonneForm(prefix="personne")
32 chercheur_form = ChercheurForm(prefix="chercheur")
33
34 variables = { 'personne_form': personne_form,
35 'chercheur_form': chercheur_form,
36 }
37
38 return render_to_response ("chercheurs/inscription.html", \
39 Context (variables),
40 context_instance = RequestContext(request))
41
42 def perso(request, id):
43 """Mock up de l'espace perso"""
44 chercheur = Chercheur.objects.get(id=id)
45 variables = { 'chercheur': chercheur,
46 }
47 return render_to_response ("chercheurs/perso.html", \
48 Context (variables),
49 context_instance = RequestContext(request))
50
51 def retrieve(request, id):
52 """Fiche du chercheur"""
53 chercheur = Chercheur.objects.get(id=id)
54 variables = { 'chercheur': chercheur,
55 }
56 return render_to_response ("chercheurs/retrieve.html", \
57 Context (variables),
58 context_instance = RequestContext(request))