2012-08-28 18:44:51 +02:00
|
|
|
from django import forms
|
2012-09-26 20:08:39 +02:00
|
|
|
from django.core import validators
|
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
def is_unique(value):
|
|
|
|
try:
|
|
|
|
User.objects.get(email=value)
|
|
|
|
raise ValidationError(u'%s is already registered' % value)
|
|
|
|
except User.DoesNotExist:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class UniqueEmailField(forms.EmailField):
|
|
|
|
default_validators = [validators.validate_email, is_unique]
|
2012-08-28 18:44:51 +02:00
|
|
|
|
|
|
|
class RegistrationForm(forms.Form):
|
2012-09-11 19:20:01 +02:00
|
|
|
full_name = forms.CharField(max_length=100)
|
2012-09-05 16:20:39 +02:00
|
|
|
password = forms.CharField(widget=forms.PasswordInput, max_length=100)
|
2012-10-25 21:04:46 +02:00
|
|
|
terms = forms.BooleanField(required=True)
|
2012-09-28 22:47:05 +02:00
|
|
|
|
|
|
|
class HomepageForm(forms.Form):
|
|
|
|
email = UniqueEmailField()
|