Ticket #9881: patch-9881.diff
File patch-9881.diff, 3.7 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/views.py
1 1 from django.conf import settings 2 from django.contrib.auth import REDIRECT_FIELD_NAME 2 from django.contrib.auth import REDIRECT_FIELD_NAME, SITE_KEYWORD 3 3 from django.contrib.auth.decorators import login_required 4 4 from django.contrib.auth.forms import AuthenticationForm 5 5 from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm, PasswordChangeForm … … 38 38 return render_to_response(template_name, { 39 39 'form': form, 40 40 redirect_field_name: redirect_to, 41 'site_name': current_site.name, 41 'site_name': current_site.name, # do not remove for backward compatibility 42 SITE_KEYWORD: current_site, 42 43 }, context_instance=RequestContext(request)) 43 44 login = never_cache(login) 44 45 -
django/contrib/auth/__init__.py
5 5 SESSION_KEY = '_auth_user_id' 6 6 BACKEND_SESSION_KEY = '_auth_user_backend' 7 7 REDIRECT_FIELD_NAME = 'next' 8 SITE_KEYWORD = 'site' 8 9 9 10 def load_backend(path): 10 11 i = path.rfind('.') -
django/contrib/auth/tests/views.py
3 3 import re 4 4 5 5 from django.conf import settings 6 from django.contrib.sites.models import Site, RequestSite 6 7 from django.contrib.auth.models import User 8 from django.contrib.auth.views import login as login_view, SITE_KEYWORD 7 9 from django.test import TestCase 8 10 from django.core import mail 11 from django.core.urlresolvers import reverse 9 12 10 13 class PasswordResetTest(TestCase): 11 14 fixtures = ['authtestdata.json'] … … 162 165 self.fail_login() 163 166 self.login(password='password1') 164 167 168 class LoginTest(TestCase): 169 fixtures = ['authtestdata.json'] 170 urls = 'django.contrib.auth.urls' 171 172 def setUp(self): 173 self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS 174 settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),) 175 176 def tearDown(self): 177 settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS 178 179 def test_current_site_in_context_after_login(self): 180 response = self.client.get(reverse(login_view)) 181 self.assertEquals(response.status_code, 200) 182 self.assertTrue(SITE_KEYWORD in response.context) 183 184 if Site._meta.installed: 185 current_site = Site.objects.get_current() 186 else: 187 current_site = RequestSite(request) 188 189 self.assertEquals(current_site, response.context[SITE_KEYWORD]) -
django/contrib/auth/tests/__init__.py
1 1 from django.contrib.auth.tests.basic import BASIC_TESTS 2 2 from django.contrib.auth.tests.views \ 3 import PasswordResetTest, ChangePasswordTest 3 import PasswordResetTest, ChangePasswordTest, LoginTest 4 4 from django.contrib.auth.tests.forms import FORM_TESTS 5 5 from django.contrib.auth.tests.remote_user \ 6 6 import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest … … 14 14 'FORM_TESTS': FORM_TESTS, 15 15 'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS, 16 16 'CHANGEPASSWORD_TESTS': ChangePasswordTest, 17 'LOGIN_TESTS': LoginTest, 17 18 }