b4cc42bfbe53c79a5556a8a2e9ba43c1e09f182e
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / chercheurs / views.py
1 # Create your views here.
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 inscription(request):
10 if request.method == 'POST':
11 personne_form = PersonneForm (request.POST, prefix="personne")
12 chercheur_form = ChercheurForm (request.POST, prefix="chercheur")
13 if personne_form.is_valid():
14 if chercheur_form.is_valid():
15 p = personne_form.save()
16 c = chercheur_form.save(commit=False)
17 c.personne = p
18 c.save()
19 else:
20 personne_form = PersonneForm(prefix="personne")
21 chercheur_form = ChercheurForm(prefix="chercheur")
22
23 variables = { 'personne_form': personne_form,
24 'chercheur_form': chercheur_form,
25 }
26
27 return render_to_response ("chercheurs/inscription.html", \
28 Context (variables),
29 context_instance = RequestContext(request))