3 from django import forms
4 from django.utils import simplejson
6 from .models import Submission, Attachment
9 class WTEMForm(forms.ModelForm):
14 def __init__(self, *args, **kwargs):
15 super(WTEMForm, self).__init__(*args, **kwargs)
17 ## @@ move this one level up
18 f = file(os.path.dirname(__file__) + '/fixtures/exercises.json')
19 exercises = simplejson.loads(f.read())
22 for exercise in exercises:
23 if exercise['type'] != 'file_upload':
25 self.fields['attachment_' + exercise['name']] = forms.FileField(required = False)
28 submission = super(WTEMForm, self).save()
29 for file in self.files.values():
30 attachment = Attachment(file = file, submission = submission)