aboutsummaryrefslogtreecommitdiffstats
path: root/account/forms.py
blob: 6a566e9d38d350fe138f8bb6ffba184c94e10a35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-

"""
account/forms.py for skaschool
"""

from django import forms
from registration.forms import RegistrationFormUniqueEmail
from django.utils.translation import ugettext_lazy as _


class UserRegForm(RegistrationFormUniqueEmail):
    """
    based on 'django-registration' RegistrationFormUniqueEmail
    add fields 'realname', 'gender', 'institute' and 'captcha'
    """
    # XXX: keep consistent with GENDERS in 'models.UserProfile'
    GENDERS = (
        ('M', _("Male")),
        ('F', _("Female")),
        ('X', _("Secret")),
    )
    realname = forms.CharField(max_length=30, label=_("Name"))
    gender = forms.ChoiceField(choices=GENDERS, label=_("Gender"))
    institute = forms.CharField(max_length=100, label=_("Institute"))

    def __init__(self, *args, **kw):
        super(UserRegForm, self).__init__(*args, **kw)
        # order form fields
        self.fields.keyOrder = [
                'username',
                'email',
                'password1',
                'password2',
                'realname',
                'gender',
                'institute',
        ]