Ticket #3011: #3011-extendable auth_user.diff
File #3011-extendable auth_user.diff, 3.5 KB (added by , 14 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 … … 198 199 return False 199 200 200 201 201 class User (models.Model):202 class UserTemplate(models.Model): 202 203 """ 203 204 Users within the Django authentication system are represented by this model. 204 205 … … 222 223 class Meta: 223 224 verbose_name = _('user') 224 225 verbose_name_plural = _('users') 226 abstract = True 225 227 226 228 def __unicode__(self): 227 229 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'][User.__name__.lower()] 313 else: 314 class User(UserTemplate): 315 class Meta: 316 verbose_name = _('user') 317 verbose_name_plural = _('users') 318 290 319 class Message(models.Model): 291 320 """ 292 321 The message system is a lightweight way to queue messages for given -
django/contrib/admin/sites.py
1 1 import re 2 2 from django import http, template 3 3 from django.contrib.admin import ModelAdmin, actions 4 from django.contrib.admin.forms import AdminAuthenticationForm5 4 from django.contrib.auth import REDIRECT_FIELD_NAME 6 5 from django.contrib.contenttypes import views as contenttype_views 7 6 from django.views.decorators.csrf import csrf_protect … … 315 314 Displays the login form for the given HttpRequest. 316 315 """ 317 316 from django.contrib.auth.views import login 317 from django.contrib.admin.forms import AdminAuthenticationForm 318 318 context = { 319 319 'title': _('Log in'), 320 320 'root_path': self.root_path,