2
|
1 |
from django import forms
|
|
2 |
|
4
|
3 |
from spoken_tut.upload.models import Participant
|
2
|
4 |
|
|
5 |
class ParticipantForm(forms.ModelForm):
|
17
|
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 |
|
2
|
18 |
class Meta:
|
|
19 |
model = Participant
|
|
20 |
|