config nb chercheurs sur accueil et debut fiche chercheur
[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 variables = { 'chercheurs': chercheurs,
13 }
14 return render_to_response ("chercheurs/repertoire.html", \
15 Context (variables),
16 context_instance = RequestContext(request))
17
18 def inscription(request):
19 if request.method == 'POST':
20 personne_form = PersonneForm (request.POST, prefix="personne")
21 chercheur_form = ChercheurForm (request.POST, prefix="chercheur")
22 if personne_form.is_valid():
23 if chercheur_form.is_valid():
24 p = personne_form.save()
25 c = chercheur_form.save(commit=False)
26 c.personne = p
27 c.save()
28 else:
29 personne_form = PersonneForm(prefix="personne")
30 chercheur_form = ChercheurForm(prefix="chercheur")
31
32 variables = { 'personne_form': personne_form,
33 'chercheur_form': chercheur_form,
34 }
35
36 return render_to_response ("chercheurs/inscription.html", \
37 Context (variables),
38 context_instance = RequestContext(request))
39
40 def perso(request, id):
41 """Mock up de l'espace perso"""
42 chercheur = Chercheur.objects.get(id=id)
43 variables = { 'chercheur': chercheur,
44 }
45 return render_to_response ("chercheurs/perso.html", \
46 Context (variables),
47 context_instance = RequestContext(request))
48
49 def retrieve(request, id):
50 """Fiche du chercheur"""
51 chercheur = Chercheur.objects.get(id=id)
52 variables = { 'chercheur': chercheur,
53 }
54 return render_to_response ("chercheurs/retrieve.html", \
55 Context (variables),
56 context_instance = RequestContext(request))