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.

from django import forms

from spoken_tut.upload.models import Participant


class ParticipantForm(forms.ModelForm):
  def clean_other_lang(self):
    """Cleaner for validating Other language field.
    """
    cleaned_data = self.cleaned_data
    lang = cleaned_data.get('language')
    other_lang = cleaned_data.get('other_lang')
    if lang == 'Other' and not other_lang:
      raise forms.ValidationError('Please fill in the other language field.')

    return other_lang

  def clean(self):
    """Form cleaner for accepting the terms and conditions.
    """
    cleaned_data = self.cleaned_data
    accept = cleaned_data.get('accept')
    if not accept:
      raise forms.ValidationError(
          'You need to accept the terms and condition for uploading the data.')

    return cleaned_data

  class Meta:
    model = Participant