]> wagnertech.de Git - SVBaL.git/blob - python/eh_util/eh_abgleich/views.py
Erste Version
[SVBaL.git] / python / eh_util / eh_abgleich / views.py
1 from django.shortcuts import render
2 from django.http import HttpResponse, HttpResponseRedirect
3 from eh_abgleich.forms import UploadFileForm, DocumentForm
4
5 # Create your views here.
6
7
8 def index(request):
9     return HttpResponse("Hello, world. You're at the polls index.")
10
11
12 # Imaginary function to handle an uploaded file.
13 #from somewhere import handle_uploaded_file
14
15 def upload_file(request):
16     if request.method == 'POST':
17         form = UploadFileForm(request.POST, request.FILES)
18         if form.is_valid():
19             #handle_uploaded_file(request.FILES['file'])
20             return HttpResponseRedirect('/success/url/')
21     else:
22         form = UploadFileForm()
23     return render(request, 'upload.html', {'form': form})
24
25 def list(request):
26     # Handle file upload
27     if request.method == 'POST':
28         form = DocumentForm(request.POST, request.FILES)
29         if form.is_valid():
30             #newdoc = Document(docfile = request.FILES['docfile'])
31             #newdoc.save()
32
33             # Redirect to the document list after POST
34             return HttpResponseRedirect(reverse('list'))
35     else:
36         form = DocumentForm() # A empty, unbound form
37
38     # Load documents for the list page
39     #documents = Document.objects.all()
40     documents = {}
41
42
43     # Render list page with the documents and the form
44     return render(request, 'list.html', {'documents': documents, 'form': form})