upload/forms.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Thu, 03 Sep 2009 18:37:48 +0530
changeset 18 07408d1ced76
parent 17 08a47999f316
child 19 6af9056ccac9
permissions -rw-r--r--
Added CSS and I accept terms and condition.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     1
from django import forms
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     2
4
ac11fee16880 Updated settings.py
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 3
diff changeset
     3
from spoken_tut.upload.models import Participant
2
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     4
18
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
     5
2
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     6
class ParticipantForm(forms.ModelForm):
18
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
     7
  def clean_other_lang(self):
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
     8
    """Cleaner for validating Other language field.
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
     9
    """
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    10
    cleaned_data = self.cleaned_data
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    11
    lang = cleaned_data.get('language')
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    12
    other_lang = cleaned_data.get('other_lang')
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    13
    if lang == 'Other' and not other_lang:
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    14
      raise forms.ValidationError('Please fill in the other language field.')
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    15
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    16
    return other_lang
17
08a47999f316 Added submissions page.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    17
18
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    18
  def clean(self):
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    19
    """Form cleaner for accepting the terms and conditions.
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    20
    """
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    21
    cleaned_data = self.cleaned_data
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    22
    accept = cleaned_data.get('accept')
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    23
    if not accept:
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    24
      raise forms.ValidationError(
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    25
          'You need to accept the terms and condition for uploading the data.')
2
4d2bbb2f3c4e Added models and views.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    26
18
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    27
    return cleaned_data
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    28
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    29
  class Meta:
07408d1ced76 Added CSS and I accept terms and condition.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 17
diff changeset
    30
    model = Participant