sdi/forms.py
author nishanth
Sat, 29 May 2010 15:46:00 +0530
changeset 20 9db4ee082d4e
parent 19 3932d9426c44
child 21 3d7a52d9ed2e
permissions -rw-r--r--
added topics choices and corresponding clean method
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
     1
from django import forms
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
     2
19
3932d9426c44 added the topics field in register form
nishanth
parents: 8
diff changeset
     3
from sage_days.sdi.models import Registrant, TOPICS_CHOICES
8
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
     4
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
     5
class RegisterForm(forms.ModelForm):
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
     6
    """ The form that is displayed to user.
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
     7
    """
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
     8
20
9db4ee082d4e added topics choices and corresponding clean method
nishanth
parents: 19
diff changeset
     9
    topics_interested = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=TOPICS_CHOICES, required=False)
8
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
    10
    class Meta:
e85ae25f920a added forms.py
nishanth
parents:
diff changeset
    11
        model = Registrant
19
3932d9426c44 added the topics field in register form
nishanth
parents: 8
diff changeset
    12
20
9db4ee082d4e added topics choices and corresponding clean method
nishanth
parents: 19
diff changeset
    13
    def clean_topics_interested(self):
9db4ee082d4e added topics choices and corresponding clean method
nishanth
parents: 19
diff changeset
    14
        """ Join the choices using PIPE character and store them.
9db4ee082d4e added topics choices and corresponding clean method
nishanth
parents: 19
diff changeset
    15
        """
9db4ee082d4e added topics choices and corresponding clean method
nishanth
parents: 19
diff changeset
    16
9db4ee082d4e added topics choices and corresponding clean method
nishanth
parents: 19
diff changeset
    17
        topics = self.cleaned_data['topics_interested']
9db4ee082d4e added topics choices and corresponding clean method
nishanth
parents: 19
diff changeset
    18
        return "|".join(topics)