Refs #26929 -- Removed extra_context parameter of contrib.auth.views.logout_then_login().

Per deprecation timeline.
This commit is contained in:
Tim Graham 2017-09-02 19:45:09 -04:00
parent 4f313e284e
commit 6e40b70bf4
4 changed files with 5 additions and 26 deletions

View File

@ -1,4 +1,3 @@
import warnings
from urllib.parse import urlparse, urlunparse
from django.conf import settings
@ -17,7 +16,6 @@ from django.http import HttpResponseRedirect, QueryDict
from django.shortcuts import resolve_url
from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.http import is_safe_url, urlsafe_base64_decode
from django.utils.translation import gettext_lazy as _
from django.views.decorators.cache import never_cache
@ -166,19 +164,10 @@ class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
return context
_sentinel = object()
def logout_then_login(request, login_url=None, extra_context=_sentinel):
def logout_then_login(request, login_url=None):
"""
Log out the user if they are logged in. Then redirect to the login 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)

View File

@ -229,3 +229,6 @@ how to remove usage of these features.
* ``contrib.auth.views.login()``, ``logout()``, ``password_change()``,
``password_change_done()``, ``password_reset()``, ``password_reset_done()``,
``password_reset_confirm()``, and ``password_reset_complete()`` are removed.
* The ``extra_context`` parameter of ``contrib.auth.views.logout_then_login()``
is removed.

View File

@ -1126,7 +1126,7 @@ implementation details see :ref:`using-the-views`.
:attr:`request.META['SERVER_NAME'] <django.http.HttpRequest.META>`.
For more on sites, see :doc:`/ref/contrib/sites`.
.. function:: logout_then_login(request, login_url=None, extra_context=None)
.. function:: logout_then_login(request, login_url=None)
Logs a user out, then redirects to the login page.
@ -1137,14 +1137,6 @@ implementation details see :ref:`using-the-views`.
* ``login_url``: The URL of the login page to redirect to.
Defaults to :setting:`settings.LOGIN_URL <LOGIN_URL>` if not supplied.
* ``extra_context``: A dictionary of context data that will be added to the
default context data passed to the template.
.. deprecated:: 1.11
The unused ``extra_context`` parameter is deprecated and will be
removed in Django 2.1.
.. class:: PasswordChangeView
.. versionadded:: 1.11

View File

@ -28,7 +28,6 @@ from django.middleware.csrf import CsrfViewMiddleware, get_token
from django.test import Client, 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.translation import LANGUAGE_SESSION_KEY
@ -821,10 +820,6 @@ 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/'