3 from django.shortcuts import render
4 from django.utils import simplejson
5 from django.conf import settings
6 from django.http import Http404
8 from .models import Submission
9 from .forms import WTEMForm
15 def form(request, key):
17 submission = Submission.objects.get(key = key)
18 except Submission.DoesNotExist:
19 if settings.DEBUG and key == '12345':
20 submission = Submission.create(first_name = 'Debug', last_name = 'Debug', email = 'debug@debug.com', key = '12345')[0]
24 ## @@ move this out of the view
25 f = file(os.path.dirname(__file__) + '/fixtures/exercises.json')
26 exercises = simplejson.loads(f.read())
29 if request.method == 'GET':
30 return render(request, 'wtem/main.html', dict(exercises = exercises))
31 elif request.method == 'POST':
32 form = WTEMForm(request.POST, request.FILES, instance = submission)
35 return render(request, 'wtem/thanks.html')