INVITATION_CODE = "You should have received one of these."
PAR_EMAIL_ADD = "Will be used for all communications."
PASSWORD = ""
STUD_FIRST_NAME = "Enter what the student prefers to go by."
STUD_LAST_NAME = ""
COURSE_1 = "Select the course enrolled in and/or getting
tutoring in."
COURSE_2 = "Select the second course, if any, enrolled in."
COURSE_3 = "Select the third course, if any, enrolled in."
HOW_HEARD_ABOUT = "Please provide specific names."
REPEAT = "This is to avoid any errors."
class RegisterForm(django.forms.Form):
"""
Represents form
data.
"""
invitation_code = CustomCharField(help_text =
INVITATION_CODE)
username = CustomCharField()
parental_email_address = EMAIL_FIELD(help_text =
PAR_EMAIL_ADD)
parental_email_address2 = EMAIL_FIELD(help_text = REPEAT)
password = CustomCharField(help_text =
PASSWORD,
widget =
PASSWORD_INPUT)
password2 = CustomCharField(help_text = REPEAT,
widget =
PASSWORD_INPUT)
student_first_name = CustomCharField(help_text =
STUD_FIRST_NAME)
student_last_name = CustomCharField(help_text =
STUD_LAST_NAME)
course_1 = CHOICE_FIELD(widget = SELECT(),
choices =
COURSE_1_CHOICES,
help_text = COURSE_1)
course_2 = CHOICE_FIELD(widget = SELECT(),
choices =
COURSE_2_CHOICES,
help_text = COURSE_2)
course_3 = CHOICE_FIELD(widget = SELECT(),
choices =
COURSE_3_CHOICES,
help_text = COURSE_3)
session = CHOICE_FIELD(widget = SELECT(),
choices =
SESSION_CHOICES)
how_heard_about_categ = CHOICE_FIELD(widget = SELECT(),
choices =
CATEG_CHOICES)
how_heard_about_detail = CustomCharField(help_text =
HOW_HEARD_ABOUT)
def clean_username(self):
"""
custom validation
code
"""
if "username" in self.cleaned_data:
username = self.cleaned_data["username"]
if USER.objects.filter(username = username):
raise VALID_ERROR("Username is not
available.")
return self.cleaned_data
def clean_invitation_code(self):
"""
custom validation
code
"""
if self.cleaned_data["invitation_code"] != "abc123":
raise VALID_ERROR("Invitation code is
invalid.")
return self.cleaned_data
def clean_parental_email_address2(self):
"""
custom validation
code
"""
cd = self.cleaned_data
if ("parental_email_address" not in
self.cleaned_data) or \
("parental_email_address2" not in
self.cleaned_data) or \
(cd["parental_email_address"] !=
cd["parental_email_address2"]):
raise VALID_ERROR("Email addresses do not
match.")
return self.cleaned_data
def clean_password2(self):
"""
custom validation
code
"""
cd = self.cleaned_data
if ("password" not in self.cleaned_data)
or \
("password2" not in self.cleaned_data)
or \
(cd["password"] != cd["password2"]):
raise VALID_ERROR("Passwords do not match.")
return self.cleaned_data
On Apr 16, 2:06 am, Kejun He <[email protected]> wrote:
> paste your form code please
>
> On Sun, Apr 15, 2012 at 11:54 PM, Andy McKay <[email protected]> wrote:
> > What does your form code look like?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.