summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Nester <andrew.nester.dev@gmail.com>2016-07-22 17:43:54 +0300
committerTim Graham <timograham@gmail.com>2016-07-28 11:57:02 -0400
commit0ba179194bc261f49b04a5eac85322b56a537e45 (patch)
treee67828d4cb5d020bb34afffab062f7c1923ac255
parent412b4126d70939903df77a72223012b2c021c511 (diff)
Fixed #26929 -- Deprecated extra_context parameter of contrib.auth.views.logout_then_login().
-rw-r--r--django/contrib/auth/views.py11
-rw-r--r--docs/internals/deprecation.txt3
-rw-r--r--docs/releases/1.11.txt3
-rw-r--r--docs/topics/auth/default.txt5
-rw-r--r--tests/auth_tests/test_views.py5
5 files changed, 26 insertions, 1 deletions
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 12bb666dec..60e150a0bf 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -177,11 +177,20 @@ def logout(request, *args, **kwargs):
return LogoutView.as_view(**kwargs)(request, *args, **kwargs)
+_sentinel = object()
+
+
@deprecate_current_app
-def logout_then_login(request, login_url=None, extra_context=None):
+def logout_then_login(request, login_url=None, extra_context=_sentinel):
"""
Logs out the user if they are logged in. Then redirects to the log-in page.
"""
+ if extra_context is not _sentinel:
+ warnings.warn(
+ "The unused `extra_context` parameter to `logout_then_login` "
+ "is deprecated.", RemovedInDjango21Warning
+ )
+
if not login_url:
login_url = settings.LOGIN_URL
login_url = resolve_url(login_url)
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 23b7a2d0b2..400fcf8789 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -20,6 +20,9 @@ details on these changes.
``password_reset_confirm()``, and ``password_reset_complete()`` will be
removed.
+* The ``extra_context`` parameter of ``contrib.auth.views.logout_then_login()``
+ will be removed.
+
.. _deprecation-removed-in-2.0:
2.0
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index 061f9a4fd1..3c220cc22d 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -366,6 +366,9 @@ Miscellaneous
:class:`~django.contrib.auth.views.LoginView` and
:class:`~django.contrib.auth.views.LogoutView`.
+* The unused ``extra_context`` parameter of
+ ``contrib.auth.views.logout_then_login()`` is deprecated.
+
* ``contrib.auth``’s ``password_change()``, ``password_change_done()``,
``password_reset()``, ``password_reset_done()``, ``password_reset_confirm()``,
and ``password_reset_complete()`` function-based views are deprecated in favor
diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt
index 70798db28e..60178348e9 100644
--- a/docs/topics/auth/default.txt
+++ b/docs/topics/auth/default.txt
@@ -1179,6 +1179,11 @@ implementation details see :ref:`using-the-views`.
The ``current_app`` parameter is deprecated and will be removed in
Django 2.0. Callers should set ``request.current_app`` instead.
+ .. deprecated:: 1.11
+
+ The unused ``extra_context`` parameter is deprecated and will be
+ removed in Django 2.1.
+
.. function:: password_change(request, template_name='registration/password_change_form.html', post_change_redirect=None, password_change_form=PasswordChangeForm, current_app=None, extra_context=None)
.. deprecated:: 1.11
diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py
index 32c51e41a0..f44c21ac2a 100644
--- a/tests/auth_tests/test_views.py
+++ b/tests/auth_tests/test_views.py
@@ -27,6 +27,7 @@ from django.middleware.csrf import CsrfViewMiddleware, get_token
from django.test import TestCase, override_settings
from django.test.utils import patch_logger
from django.urls import NoReverseMatch, reverse, reverse_lazy
+from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.encoding import force_text
from django.utils.http import urlquote
from django.utils.six.moves.urllib.parse import ParseResult, urlparse
@@ -734,6 +735,10 @@ class LogoutThenLoginTests(AuthViewsTestCase):
self.confirm_logged_out()
self.assertRedirects(response, '/custom/', fetch_redirect_response=False)
+ def test_deprecated_extra_context(self):
+ with self.assertRaisesMessage(RemovedInDjango21Warning, 'The unused `extra_context` parameter'):
+ logout_then_login(None, extra_context={})
+
class LoginRedirectAuthenticatedUser(AuthViewsTestCase):
dont_redirect_url = '/login/redirect_authenticated_user_default/'