summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-04-01 16:37:48 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-04-01 16:37:48 +0000
commit19b9211a3b5424e7908a288c5008bf972cc472f4 (patch)
tree50fbccec86b5d8c8caae24599114d103ba8b0077
parente6ad4fb901c4d3bbaff1ad01bb8cc93852c20e1e (diff)
Fixed #9881: Added the to the login view context, not just the site's name. Thanks, nessita.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10330 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/tests/__init__.py3
-rw-r--r--django/contrib/auth/tests/views.py23
-rw-r--r--django/contrib/auth/views.py1
3 files changed, 26 insertions, 1 deletions
diff --git a/django/contrib/auth/tests/__init__.py b/django/contrib/auth/tests/__init__.py
index e878d43a7b..bd86111586 100644
--- a/django/contrib/auth/tests/__init__.py
+++ b/django/contrib/auth/tests/__init__.py
@@ -1,6 +1,6 @@
from django.contrib.auth.tests.basic import BASIC_TESTS
from django.contrib.auth.tests.views \
- import PasswordResetTest, ChangePasswordTest
+ import PasswordResetTest, ChangePasswordTest, LoginTest
from django.contrib.auth.tests.forms import FORM_TESTS
from django.contrib.auth.tests.remote_user \
import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest
@@ -14,4 +14,5 @@ __test__ = {
'FORM_TESTS': FORM_TESTS,
'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS,
'CHANGEPASSWORD_TESTS': ChangePasswordTest,
+ 'LOGIN_TESTS': LoginTest,
}
diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py
index 3e5cbabf05..754241d5d2 100644
--- a/django/contrib/auth/tests/views.py
+++ b/django/contrib/auth/tests/views.py
@@ -3,9 +3,12 @@ import os
import re
from django.conf import settings
+from django.contrib.auth.forms import AuthenticationForm
+from django.contrib.sites.models import Site, RequestSite
from django.contrib.auth.models import User
from django.test import TestCase
from django.core import mail
+from django.core.urlresolvers import reverse
class PasswordResetTest(TestCase):
fixtures = ['authtestdata.json']
@@ -162,3 +165,23 @@ class ChangePasswordTest(TestCase):
self.fail_login()
self.login(password='password1')
+class LoginTest(TestCase):
+ fixtures = ['authtestdata.json']
+ urls = 'django.contrib.auth.urls'
+
+ def setUp(self):
+ self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
+ settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
+
+ def tearDown(self):
+ settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
+
+ def test_current_site_in_context_after_login(self):
+ response = self.client.get(reverse('django.contrib.auth.views.login'))
+ self.assertEquals(response.status_code, 200)
+ site = Site.objects.get_current()
+ self.assertEquals(response.context['site'], site)
+ self.assertEquals(response.context['site_name'], site.name)
+ self.assert_(isinstance(response.context['form'], AuthenticationForm),
+ 'Login form is not an AuthenticationForm')
+ \ No newline at end of file
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index e1f0d43c00..18572f1584 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -38,6 +38,7 @@ def login(request, template_name='registration/login.html', redirect_field_name=
return render_to_response(template_name, {
'form': form,
redirect_field_name: redirect_to,
+ 'site': current_site,
'site_name': current_site.name,
}, context_instance=RequestContext(request))
login = never_cache(login)