event/forms.py
author nishanth
Tue, 06 Jul 2010 23:31:33 +0530
changeset 89 f8e25dea5222
parent 86 404e9c1b8cff
permissions -rw-r--r--
updated timing for each question. increased timing actually
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
601057af86c2 implemented event create
nishanth
parents:
diff changeset
     1
from django import forms
601057af86c2 implemented event create
nishanth
parents:
diff changeset
     2
62
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
     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
601057af86c2 implemented event create
nishanth
parents:
diff changeset
     5
601057af86c2 implemented event create
nishanth
parents:
diff changeset
     6
class EventCreateForm(forms.ModelForm):
601057af86c2 implemented event create
nishanth
parents:
diff changeset
     7
601057af86c2 implemented event create
nishanth
parents:
diff changeset
     8
    class Meta:
601057af86c2 implemented event create
nishanth
parents:
diff changeset
     9
        model = Event
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    10
        fields = ['title', 'start_date', 'stop_date']
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    11
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    12
    def clean_start_date(self):
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    13
        return self.cleaned_data['start_date']
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    14
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    15
    def clean_stop_date(self):
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    16
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    17
        stop_date = self.cleaned_data['stop_date']
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    18
        start_date = self.clean_start_date()
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    19
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    20
        if start_date > stop_date:
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    21
            raise forms.ValidationError("Event cannot stop before it starts")
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    22
601057af86c2 implemented event create
nishanth
parents:
diff changeset
    23
        return self.cleaned_data['stop_date']
12
81cd0140a0f2 created the register user functionality.
nishanth
parents: 9
diff changeset
    24
62
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    25
class OpenQuizForm(forms.Form):
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    26
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    27
    quiz_num = forms.ChoiceField(required=True, widget=forms.RadioSelect, choices=QUIZ_CHOICES)
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    28
    topics = forms.MultipleChoiceField(required=True, widget=forms.CheckboxSelectMultiple, choices=TOPIC_CHOICES,)
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    29
    
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    30
    def clean_topics(self):
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    31
baddb55f8da7 created a form for opening quiz
nishanth
parents: 12
diff changeset
    32
        return self.cleaned_data["topics"]
85
451be7b1de20 created form for editing and used it in view
nishanth
parents: 63
diff changeset
    33
451be7b1de20 created form for editing and used it in view
nishanth
parents: 63
diff changeset
    34
class EditQuestionForm(forms.ModelForm):
451be7b1de20 created form for editing and used it in view
nishanth
parents: 63
diff changeset
    35
451be7b1de20 created form for editing and used it in view
nishanth
parents: 63
diff changeset
    36
    class Meta:
451be7b1de20 created form for editing and used it in view
nishanth
parents: 63
diff changeset
    37
        model = QuestionBank