Files
zulip/zephyr/forms.py
Waseem Daher c894bab738 Compute a user's realm from the verified email address, not a user-passed field.
(imported from commit 5c220a7b9e4b137b5c98b286e409004318565137)
2012-10-25 16:50:00 -04:00

23 lines
712 B
Python

from django import forms
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]
class RegistrationForm(forms.Form):
full_name = forms.CharField(max_length=100)
password = forms.CharField(widget=forms.PasswordInput, max_length=100)
terms = forms.BooleanField(required=True)
class HomepageForm(forms.Form):
email = UniqueEmailField()