mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 20:40:17 +02:00
* Added German Translations Translated using https://docs.djangoproject.com/en/1.9/topics/i18n/translation/ Added language drop down menu's for base.html, registration & login pages Known issues: * Translated items in whtracker>create signature remain translated when posted * No date/time localisation for Fleet/Structure timers * Added time locale Added date/time locale to *Structure Timers *Fleet Timers *Fleet timer form datetimepicker.js Fixed a bug where the bootstrap label didn't show up when making a structure timer using the translated form Missed some base.html translations * Small translation error Some obscure SRP strings went unnoticed for context review * FAT & Fleet-up German Translations + a fix in settings.py.example The only small thing not done is German Date/Time locale for Fleet-up * Compiled de/django.po
45 lines
2.3 KiB
Python
45 lines
2.3 KiB
Python
from django import forms
|
|
from django.contrib.auth.models import User
|
|
from django.utils.translation import ugettext_lazy as _
|
|
import re
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class RegistrationForm(forms.Form):
|
|
username = forms.CharField(label=_('Username'), max_length=30, required=True)
|
|
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(), required=True)
|
|
password_again = forms.CharField(label=_('Password Again'), widget=forms.PasswordInput(), required=True)
|
|
email = forms.CharField(label=_('Email'), max_length=254, required=True)
|
|
email_again = forms.CharField(label=_('Email Again'), max_length=254, required=True)
|
|
|
|
def clean(self):
|
|
if ' ' in self.cleaned_data['username']:
|
|
logger.debug("RegistrationForm username contains spaces. Raising ValidationError. Username: %s" % self.cleaned_data['username'])
|
|
raise forms.ValidationError(u'Username cannot contain a space')
|
|
|
|
# We attempt to get the user object if we succeed we know email as been used
|
|
try:
|
|
User.objects.get(email=self.cleaned_data['email'])
|
|
logger.debug("RegistrationForm email already registered. Raising ValidationError")
|
|
raise forms.ValidationError(u'Email as already been used')
|
|
except:
|
|
pass
|
|
|
|
if not re.match("^\w+$", self.cleaned_data['username']):
|
|
logger.debug("RegistrationForm username contains non-alphanumeric characters. Raising ValueError. Username: %s" % self.cleaned_data['username'])
|
|
raise forms.ValidationError(u'Username contains illegal characters')
|
|
|
|
if 'password' in self.cleaned_data and 'password_again' in self.cleaned_data:
|
|
if self.cleaned_data['password'] != self.cleaned_data['password_again']:
|
|
logger.debug("RegistrationForm password mismatch. Raising ValueError")
|
|
raise forms.ValidationError(u'Passwords do not match')
|
|
|
|
if 'email' in self.cleaned_data and 'email_again' in self.cleaned_data:
|
|
if self.cleaned_data['email'] != self.cleaned_data['email_again']:
|
|
logger.debug("RegistrationForm email mismatch. Raising ValidationError")
|
|
raise forms.ValidationError(u'Emails do not match')
|
|
|
|
return self.cleaned_data
|