author | nishanth |
Tue, 06 Jul 2010 23:31:33 +0530 | |
changeset 89 | f8e25dea5222 |
parent 86 | 404e9c1b8cff |
permissions | -rw-r--r-- |
9 | 1 |
from django import forms |
2 |
||
62 | 3 |
from offline.event.models import Event, QUIZ_CHOICES |
86
404e9c1b8cff
now questions are displayed properly in edit_question page. hav to implement the submit and stuff
nishanth
parents:
85
diff
changeset
|
4 |
from offline.quiz.models import QuestionBank, TOPIC_CHOICES |
9 | 5 |
|
6 |
class EventCreateForm(forms.ModelForm): |
|
7 |
||
8 |
class Meta: |
|
9 |
model = Event |
|
10 |
fields = ['title', 'start_date', 'stop_date'] |
|
11 |
||
12 |
def clean_start_date(self): |
|
13 |
return self.cleaned_data['start_date'] |
|
14 |
||
15 |
def clean_stop_date(self): |
|
16 |
||
17 |
stop_date = self.cleaned_data['stop_date'] |
|
18 |
start_date = self.clean_start_date() |
|
19 |
||
20 |
if start_date > stop_date: |
|
21 |
raise forms.ValidationError("Event cannot stop before it starts") |
|
22 |
||
23 |
return self.cleaned_data['stop_date'] |
|
12 | 24 |
|
62 | 25 |
class OpenQuizForm(forms.Form): |
26 |
||
27 |
quiz_num = forms.ChoiceField(required=True, widget=forms.RadioSelect, choices=QUIZ_CHOICES) |
|
28 |
topics = forms.MultipleChoiceField(required=True, widget=forms.CheckboxSelectMultiple, choices=TOPIC_CHOICES,) |
|
29 |
||
30 |
def clean_topics(self): |
|
31 |
||
32 |
return self.cleaned_data["topics"] |
|
85 | 33 |
|
34 |
class EditQuestionForm(forms.ModelForm): |
|
35 |
||
36 |
class Meta: |
|
37 |
model = QuestionBank |