1 from django.shortcuts import render
2 from django.http import HttpResponse, HttpResponseRedirect
3 from eh_abgleich.forms import UploadFileForm, DocumentForm
5 # Create your views here.
9 return HttpResponse("Hello, world. You're at the polls index.")
12 # Imaginary function to handle an uploaded file.
13 #from somewhere import handle_uploaded_file
15 def upload_file(request):
16 if request.method == 'POST':
17 form = UploadFileForm(request.POST, request.FILES)
19 #handle_uploaded_file(request.FILES['file'])
20 return HttpResponseRedirect('/success/url/')
22 form = UploadFileForm()
23 return render(request, 'upload.html', {'form': form})
27 if request.method == 'POST':
28 form = DocumentForm(request.POST, request.FILES)
30 #newdoc = Document(docfile = request.FILES['docfile'])
33 # Redirect to the document list after POST
34 return HttpResponseRedirect(reverse('list'))
36 form = DocumentForm() # A empty, unbound form
38 # Load documents for the list page
39 #documents = Document.objects.all()
43 # Render list page with the documents and the form
44 return render(request, 'list.html', {'documents': documents, 'form': form})