upload/forms.py
changeset 17 08a47999f316
parent 4 ac11fee16880
child 18 07408d1ced76
--- a/upload/forms.py	Thu Sep 03 00:17:30 2009 +0530
+++ b/upload/forms.py	Thu Sep 03 17:31:12 2009 +0530
@@ -3,6 +3,18 @@
 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.')
+
 	class Meta:
 		model = Participant