equal
deleted
inserted
replaced
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 |