Ticket #3011: 3011-r10115.diff
File 3011-r10115.diff, 2.9 KB (added by , 16 years ago) |
---|
-
django/conf/global_settings.py
379 379 # The number of days a password reset link is valid for 380 380 PASSWORD_RESET_TIMEOUT_DAYS = 3 381 381 382 # The class to use as the default AUTH_USER for the authentication system. 383 AUTH_USER_MODULE = None 384 382 385 ########### 383 386 # TESTING # 384 387 ########### -
django/contrib/auth/models.py
1 1 import datetime 2 2 import urllib 3 3 4 from django.conf import settings 4 5 from django.contrib import auth 5 6 from django.core.exceptions import ImproperlyConfigured 6 7 from django.db import models … … 119 120 from random import choice 120 121 return ''.join([choice(allowed_chars) for i in range(length)]) 121 122 122 class User (models.Model):123 class UserTemplate(models.Model): 123 124 """Users within the Django authentication system are represented by this model. 124 125 125 126 Username and password are required. Other fields are optional. … … 142 143 class Meta: 143 144 verbose_name = _('user') 144 145 verbose_name_plural = _('users') 146 abstract = True 145 147 146 148 def __unicode__(self): 147 149 return self.username … … 287 289 raise SiteProfileNotAvailable 288 290 return self._profile_cache 289 291 292 if settings.AUTH_USER_MODULE is not None: 293 # Grab the AUTH_USER_MODULE path and classname from the settings. 294 # auth_user_module_parts[0] = module path 295 # auth_user_module_parts[1] = class name 296 auth_user_module_parts = settings.AUTH_USER_MODULE.rsplit('.', 1) 297 auth_user_module = __import__(auth_user_module_parts[0], {}, {}, [auth_user_module_parts[0]]) 298 # Store the auth_user model so it is accessible with the standard 299 # 'from django.contrib.auth.models import User' 300 User = getattr(auth_user_module, auth_user_module_parts[1]) 301 302 # Add te User model to the django models cache 303 # These two lines allow the custom auth_user model to play nicely with syncdb 304 # and other systems that rely on functions like 305 # django.db.models.loading.get_model(...) 306 from django.db.models.loading import cache 307 cache.register_models('auth', User) 308 309 # We need to remove whatever we used as the AUTH_USER_MODUlE from the 310 # db cache so apps like contenttypes don't think that it's part 311 # of contrib.auth 312 del cache.app_models['auth'][auth_user_module_parts[1].lower()] 313 else: 314 class User(UserTemplate): 315 class Meta: 316 verbose_name = _('user') 317 verbose_name_plural = _('users') 318 319 290 320 class Message(models.Model): 291 321 """ 292 322 The message system is a lightweight way to queue messages for given