Commit da719daa authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos

Remove obsolete app

parent ca345a18
from django.conf import settings
# This patch was retrieved from: https://github.com/GoodCloud/django-longer-username
def MAX_USERNAME_LENGTH():
if hasattr(settings,"MAX_USERNAME_LENGTH"):
return settings.MAX_USERNAME_LENGTH
else:
return 255
from django.utils.translation import ugettext as _
from django.core.validators import MaxLengthValidator
from django.contrib.auth import forms as auth_forms
from django import forms
from monkey_patch import MAX_USERNAME_LENGTH
def update_username_field(field):
field.widget.attrs['maxlength'] = MAX_USERNAME_LENGTH()
field.max_length = MAX_USERNAME_LENGTH()
field.help_text = _("Required, %s characters or fewer. Only letters, numbers, and characters such as @.+_- are allowed." % MAX_USERNAME_LENGTH())
# we need to find the MaxLengthValidator and change its
# limit_value otherwise the auth forms will fail validation
for v in field.validators:
if isinstance(v, MaxLengthValidator):
v.limit_value = MAX_USERNAME_LENGTH()
class UserCreationForm(auth_forms.UserCreationForm):
def __init__(self, *args, **kwargs):
super(UserCreationForm, self).__init__(*args, **kwargs)
update_username_field(self.fields['username'])
class UserChangeForm(auth_forms.UserChangeForm):
def __init__(self, *args, **kwargs):
super(UserChangeForm, self).__init__(*args, **kwargs)
update_username_field(self.fields['username'])
class AuthenticationForm(auth_forms.AuthenticationForm):
def __init__(self, *args, **kwargs):
super(AuthenticationForm, self).__init__(*args, **kwargs)
update_username_field(self.fields['username'])
from django.utils.translation import ugettext as _
from django.db.models.signals import class_prepared
from django.core.validators import MaxLengthValidator
from monkey_patch import MAX_USERNAME_LENGTH
def longer_username(sender, *args, **kwargs):
if sender.__name__ == "User" and sender.__module__ == "django.contrib.auth.models":
sender._meta.get_field("username").max_length = MAX_USERNAME_LENGTH()
# For Django 1.2 to work, the validator has to be declared apart from max_length
sender._meta.get_field("username").validators = [MaxLengthValidator(MAX_USERNAME_LENGTH())]
#sender._meta.get_field("username").help_text = _("Required, %s characters or fewer. Only letters, numbers, and @, ., +, -, or _ characters." % MAX_USERNAME_LENGTH())
class_prepared.connect(longer_username)
# Create your views here.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment