mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
We add a few templates for django-confirmation. We define a "PreregistrationForm" which is validated by accounts_home, which then generates a confirmation object and emails the user. This required creating a new table for a PreregistrationUser with an email and status (confirmed) field. The register function now no longer accepts a "email" field in the form and deals only with confirmation IDs to determine the email used to sign up a user. (imported from commit 4fcde04530aa7ad4de84579668daee7290b424ac)
23 lines
711 B
Python
23 lines
711 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)
|
|
domain = forms.CharField(max_length=100)
|
|
|
|
class HomepageForm(forms.Form):
|
|
email = UniqueEmailField()
|