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