mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
Here we introduce a new manage.py command, activate_mit, which takes a number of usernames and sends out emails to the users with instructions on how to activate their accounts. (imported from commit f14401b55f915698e83ff27b86434f53e64685f3)
30 lines
906 B
Python
30 lines
906 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
|
|
|
|
def is_active(value):
|
|
try:
|
|
if User.objects.get(email=value).is_active:
|
|
raise ValidationError(u'%s is already active' % 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()
|