Ticket #3011: 3011.3.diff

File 3011.3.diff, 6.5 KB (added by Densetsu no Ero-sennin <densetsu.no.ero.sennin@…>, 8 years ago)

oh sorry, my previous patch was against newforms-admin branch, here's the patch against trunk [6023]

  • django/conf/global_settings.py

     
    328328
    329329LOGIN_REDIRECT_URL = '/accounts/profile/'
    330330
     331# The class to use as the default AUTH_USER for the authentication system.
     332AUTH_USER_MODULE = 'django.contrib.auth.default_user.User'
     333
    331334###########
    332335# TESTING #
    333336###########
  • django/contrib/auth/default_user.py

     
     1from django.db import models
     2from django.core import validators
     3from django.utils.translation import gettext_lazy as _
     4
     5from django.contrib.auth.models import Group, Permission, UserManager, UserTemplate
     6
     7import datetime
     8
     9class User(models.Model, UserTemplate):
     10    """Users within the Django authentication system are represented by this model.
     11
     12    Username and password are required. Other fields are optional.
     13    """
     14    username = models.CharField(_('username'), max_length=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
     15    first_name = models.CharField(_('first name'), max_length=30, blank=True)
     16    last_name = models.CharField(_('last name'), max_length=30, blank=True)
     17    email = models.EmailField(_('e-mail address'), blank=True)
     18    password = models.CharField(_('password'), max_length=128, help_text=_("Use '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change password form</a>."))
     19    is_staff = models.BooleanField(_('staff status'), default=False, help_text=_("Designates whether the user can log into this admin site."))
     20    is_active = models.BooleanField(_('active'), default=True, help_text=_("Designates whether this user can log into the Django admin. Unselect this instead of deleting accounts."))
     21    is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_("Designates that this user has all permissions without explicitly assigning them."))
     22    last_login = models.DateTimeField(_('last login'), default=datetime.datetime.now)
     23    date_joined = models.DateTimeField(_('date joined'), default=datetime.datetime.now)
     24    groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True,
     25        help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in."))
     26    user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True)
     27    objects = UserManager()
  • django/contrib/auth/models.py

     
    44from django.contrib.contenttypes.models import ContentType
    55from django.utils.encoding import smart_str
    66from django.utils.translation import ugettext_lazy as _
     7from django.conf import settings
    78import datetime
    89import urllib
    910
     
    103104        from random import choice
    104105        return ''.join([choice(allowed_chars) for i in range(length)])
    105106
    106 class User(models.Model):
    107     """Users within the Django authentication system are represented by this model.
    108107
    109     Username and password are required. Other fields are optional.
    110     """
    111     username = models.CharField(_('username'), max_length=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
    112     first_name = models.CharField(_('first name'), max_length=30, blank=True)
    113     last_name = models.CharField(_('last name'), max_length=30, blank=True)
    114     email = models.EmailField(_('e-mail address'), blank=True)
    115     password = models.CharField(_('password'), max_length=128, help_text=_("Use '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change password form</a>."))
    116     is_staff = models.BooleanField(_('staff status'), default=False, help_text=_("Designates whether the user can log into this admin site."))
    117     is_active = models.BooleanField(_('active'), default=True, help_text=_("Designates whether this user can log into the Django admin. Unselect this instead of deleting accounts."))
    118     is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_("Designates that this user has all permissions without explicitly assigning them."))
    119     last_login = models.DateTimeField(_('last login'), default=datetime.datetime.now)
    120     date_joined = models.DateTimeField(_('date joined'), default=datetime.datetime.now)
    121     groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True,
    122         help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in."))
    123     user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True, filter_interface=models.HORIZONTAL)
    124     objects = UserManager()
    125 
     108class UserTemplate(object):
    126109    class Meta:
    127110        verbose_name = _('user')
    128111        verbose_name_plural = _('users')
     
    280263                raise SiteProfileNotAvailable
    281264        return self._profile_cache
    282265
     266
     267# Grab the AUTH_USER_MODULE path and classname from the settings.
     268# auth_user_module_parts[0] = module path
     269# auth_user_module_parts[1] = class name
     270auth_user_module_parts = settings.AUTH_USER_MODULE.rsplit('.', 1)
     271auth_user_module = __import__(auth_user_module_parts[0], {}, {}, [auth_user_module_parts[0]])
     272# Store the auth_user model so it is accessible with the standard 'from django.contrib.auth.models import User'
     273User = getattr(auth_user_module, auth_user_module_parts[1])
     274
     275# Add the User model to the django models cache
     276# These two lines allow the custom auth_user model to play nicely with syncdb and other systems that rely
     277# on functions like django.db.models.loading.get_model(...)
     278from django.db.models.loading import cache
     279cache.register_models('auth', User)
     280
     281
    283282class Message(models.Model):
    284283    """
    285284    The message system is a lightweight way to queue messages for given users. A message is associated with a User instance (so it is only applicable for registered users). There's no concept of expiration or timestamps. Messages are created by the Django admin after successful actions. For example, "The poll Foo was created successfully." is a message.
Back to Top