--- a/upload/forms.py Thu Sep 03 17:31:12 2009 +0530
+++ b/upload/forms.py Thu Sep 03 18:37:48 2009 +0530
@@ -2,19 +2,29 @@
from spoken_tut.upload.models import Participant
+
class ParticipantForm(forms.ModelForm):
- def clean(self):
- """Cleaner for validating Other language field.
- """
- cleaned_data = self.cleaned_data
- lang = cleaned_data['language']
- other_lang = cleaned_data['other_lang']
- accept = cleaned_data['accept']
- if lang == 'Other' and not other_lang:
- raise forms.ValidationError('Please fill in the other language field.')
- if accept:
- raise forms.ValidationError('You need to accept the terms and condition for uploading the data.')
+ def clean_other_lang(self):
+ """Cleaner for validating Other language field.
+ """
+ cleaned_data = self.cleaned_data
+ lang = cleaned_data.get('language')
+ other_lang = cleaned_data.get('other_lang')
+ if lang == 'Other' and not other_lang:
+ raise forms.ValidationError('Please fill in the other language field.')
+
+ return other_lang
- class Meta:
- model = Participant
+ def clean(self):
+ """Form cleaner for accepting the terms and conditions.
+ """
+ cleaned_data = self.cleaned_data
+ accept = cleaned_data.get('accept')
+ if not accept:
+ raise forms.ValidationError(
+ 'You need to accept the terms and condition for uploading the data.')
+ return cleaned_data
+
+ class Meta:
+ model = Participant