upload/forms.py
changeset 17 08a47999f316
parent 4 ac11fee16880
child 18 07408d1ced76
equal deleted inserted replaced
16:a5bbfbe5feb1 17:08a47999f316
     1 from django import forms
     1 from django import forms
     2 
     2 
     3 from spoken_tut.upload.models import Participant
     3 from spoken_tut.upload.models import Participant
     4 
     4 
     5 class ParticipantForm(forms.ModelForm):
     5 class ParticipantForm(forms.ModelForm):
       
     6     def clean(self):
       
     7         """Cleaner for validating Other language field.
       
     8         """
       
     9         cleaned_data = self.cleaned_data
       
    10         lang = cleaned_data['language']
       
    11         other_lang = cleaned_data['other_lang']
       
    12         accept = cleaned_data['accept']
       
    13         if lang == 'Other' and not other_lang:
       
    14             raise forms.ValidationError('Please fill in the other language field.')
       
    15         if accept:
       
    16             raise forms.ValidationError('You need to accept the terms and condition for uploading the data.')
       
    17 
     6 	class Meta:
    18 	class Meta:
     7 		model = Participant
    19 		model = Participant
     8 
    20