projet cartographie preuve concept francis.ngatsi
[davin.git] / projets / cartographie / carto / formation / views.py
1 # -*- coding: utf-8 -*
2
3 # Create your views here.
4 from django.template import Context
5 from django.template.loader import get_template
6 from django.http import HttpResponse, Http404
7 #from django.contrib.auth.models import User
8 from django.shortcuts import render_to_response, get_object_or_404
9 from django.http import HttpResponseRedirect
10 #from django.contrib.auth import logout
11 from django.template import RequestContext
12 from formation.forms import *
13 from formation.models import *
14
15 import xml.etree.ElementTree as ET
16
17
18 from django.contrib.auth.decorators import login_required
19 from django.core.exceptions import ObjectDoesNotExist
20 #from django.contrib.auth.models import User
21 from datetime import datetime, timedelta
22 from django.contrib import admin
23
24 def form_formation(request):
25 form = FormationClient()
26 variables = RequestContext(request, {
27 'form': form
28 })
29 return render_to_response('saisie/form_formation.html', variables)
30
31 #def form_formation_xml(request):
32 # form = FormationClient()
33 # variables = RequestContext(request, {
34 # 'form': form
35 # })
36 # return render_to_response('saisie/form_formation.html', variables)
37
38
39 def main_page(request):
40 formations = Formation.objects.all()
41 variables = RequestContext(request, {
42 'formations': formations
43 })
44 return render_to_response('main_page.html', variables)
45
46
47 def export_xml(request, formation_id):
48 formations = Formation.objects.get(id=formation_id)
49 partenaire = Partenaire.objects.filter(formation=formation_id)
50 variables = RequestContext(request, {
51 'formations': formations,
52 'partenaire': partenaire
53 })
54 #return render_to_response('saisie/formation.xml', variables, mimetype="application/xml")
55 response = render_to_response('formation.xml', variables, mimetype="application/xml")
56 response['Content-Disposition'] = 'attachment; filename=formation.xml'
57 return response