upload/forms.py
author Shantanu <shantanu@fossee.in>
Thu, 03 Sep 2009 17:31:12 +0530
changeset 17 08a47999f316
parent 4 ac11fee16880
child 18 07408d1ced76
permissions -rw-r--r--
Added submissions page.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     1
from django import forms
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     2
4
ac11fee16880 Updated settings.py
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 3
diff changeset
     3
from spoken_tut.upload.models import Participant
2
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     4
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     5
class ParticipantForm(forms.ModelForm):
17
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
     6
    def clean(self):
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
     7
        """Cleaner for validating Other language field.
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
     8
        """
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
     9
        cleaned_data = self.cleaned_data
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    10
        lang = cleaned_data['language']
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    11
        other_lang = cleaned_data['other_lang']
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    12
        accept = cleaned_data['accept']
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    13
        if lang == 'Other' and not other_lang:
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    14
            raise forms.ValidationError('Please fill in the other language field.')
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    15
        if accept:
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    16
            raise forms.ValidationError('You need to accept the terms and condition for uploading the data.')
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    17
2
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    18
	class Meta:
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    19
		model = Participant
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    20