Browse Source

Refs #24126 -- Removed auth views' current_app parameter per deprecation timeline.

Tim Graham 8 years ago
parent
commit
9f9a3d643e
3 changed files with 21 additions and 132 deletions
  1. 1 34
      django/contrib/auth/views.py
  2. 3 0
      docs/releases/2.0.txt
  3. 17 98
      docs/topics/auth/default.txt

+ 1 - 34
django/contrib/auth/views.py

@@ -1,4 +1,3 @@
-import functools
 import warnings
 
 from django.conf import settings
@@ -18,9 +17,7 @@ from django.shortcuts import resolve_url
 from django.template.response import TemplateResponse
 from django.urls import reverse, reverse_lazy
 from django.utils.decorators import method_decorator
-from django.utils.deprecation import (
-    RemovedInDjango20Warning, RemovedInDjango21Warning,
-)
+from django.utils.deprecation import RemovedInDjango21Warning
 from django.utils.encoding import force_text
 from django.utils.http import is_safe_url, urlsafe_base64_decode
 from django.utils.six.moves.urllib.parse import urlparse, urlunparse
@@ -34,27 +31,6 @@ from django.views.generic.edit import FormView
 UserModel = get_user_model()
 
 
-def deprecate_current_app(func):
-    """
-    Handle deprecation of the current_app parameter of the views.
-    """
-    @functools.wraps(func)
-    def inner(*args, **kwargs):
-        if 'current_app' in kwargs:
-            warnings.warn(
-                "Passing `current_app` as a keyword argument is deprecated. "
-                "Instead the caller of `{0}` should set "
-                "`request.current_app`.".format(func.__name__),
-                RemovedInDjango20Warning
-            )
-            current_app = kwargs.pop('current_app')
-            request = kwargs.get('request', None)
-            if request and current_app is not None:
-                request.current_app = current_app
-        return func(*args, **kwargs)
-    return inner
-
-
 class SuccessURLAllowedHostsMixin(object):
     success_url_allowed_hosts = set()
 
@@ -125,7 +101,6 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView):
         return context
 
 
-@deprecate_current_app
 def login(request, *args, **kwargs):
     warnings.warn(
         'The login() view is superseded by the class-based LoginView().',
@@ -190,7 +165,6 @@ class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
         return context
 
 
-@deprecate_current_app
 def logout(request, *args, **kwargs):
     warnings.warn(
         'The logout() view is superseded by the class-based LogoutView().',
@@ -202,7 +176,6 @@ def logout(request, *args, **kwargs):
 _sentinel = object()
 
 
-@deprecate_current_app
 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.
@@ -242,7 +215,6 @@ def redirect_to_login(next, login_url=None,
 #   prompts for a new password
 # - password_reset_complete shows a success message for the above
 
-@deprecate_current_app
 @csrf_protect
 def password_reset(request,
                    template_name='registration/password_reset_form.html',
@@ -289,7 +261,6 @@ def password_reset(request,
     return TemplateResponse(request, template_name, context)
 
 
-@deprecate_current_app
 def password_reset_done(request,
                         template_name='registration/password_reset_done.html',
                         extra_context=None):
@@ -308,7 +279,6 @@ def password_reset_done(request,
 # Doesn't need csrf_protect since no-one can guess the URL
 @sensitive_post_parameters()
 @never_cache
-@deprecate_current_app
 def password_reset_confirm(request, uidb64=None, token=None,
                            template_name='registration/password_reset_confirm.html',
                            token_generator=default_token_generator,
@@ -359,7 +329,6 @@ def password_reset_confirm(request, uidb64=None, token=None,
     return TemplateResponse(request, template_name, context)
 
 
-@deprecate_current_app
 def password_reset_complete(request,
                             template_name='registration/password_reset_complete.html',
                             extra_context=None):
@@ -518,7 +487,6 @@ class PasswordResetCompleteView(PasswordContextMixin, TemplateView):
 @sensitive_post_parameters()
 @csrf_protect
 @login_required
-@deprecate_current_app
 def password_change(request,
                     template_name='registration/password_change_form.html',
                     post_change_redirect=None,
@@ -552,7 +520,6 @@ def password_change(request,
 
 
 @login_required
-@deprecate_current_app
 def password_change_done(request,
                          template_name='registration/password_change_done.html',
                          extra_context=None):

+ 3 - 0
docs/releases/2.0.txt

@@ -303,3 +303,6 @@ these features.
 * ``Field._get_val_from_obj()`` is removed.
 
 * ``django.template.loaders.eggs.Loader`` is removed.
+
+* The ``current_app`` parameter to the ``contrib.auth`` function-based views is
+  removed.

+ 17 - 98
docs/topics/auth/default.txt

@@ -955,7 +955,7 @@ All authentication views
 This is a list with all the views ``django.contrib.auth`` provides. For
 implementation details see :ref:`using-the-views`.
 
-.. function:: login(request, template_name=`registration/login.html`, redirect_field_name='next', authentication_form=AuthenticationForm, current_app=None, extra_context=None, redirect_authenticated_user=False)
+.. function:: login(request, template_name=`registration/login.html`, redirect_field_name='next', authentication_form=AuthenticationForm, extra_context=None, redirect_authenticated_user=False)
 
     .. deprecated:: 1.11
 
@@ -963,16 +963,7 @@ implementation details see :ref:`using-the-views`.
         :class:`LoginView`.
 
     The optional arguments of this view are similar to the class-based
-    ``LoginView`` attributes. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the
-      current view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` attribute is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``LoginView`` attributes.
 
     .. versionadded:: 1.10
 
@@ -1116,7 +1107,7 @@ implementation details see :ref:`using-the-views`.
     ``get_user()`` method which returns the authenticated user object (this
     method is only ever called after successful form validation).
 
-.. function:: logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name='next', current_app=None, extra_context=None)
+.. function:: logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name='next', extra_context=None)
 
     .. deprecated:: 1.11
 
@@ -1124,16 +1115,7 @@ implementation details see :ref:`using-the-views`.
         class-based :class:`LogoutView`.
 
     The optional arguments of this view are similar to the class-based
-    ``LogoutView`` attributes. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the
-      current view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` attribute is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``LogoutView`` attributes.
 
 .. class:: LogoutView
 
@@ -1178,7 +1160,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, current_app=None, extra_context=None)
+.. function:: logout_then_login(request, login_url=None, extra_context=None)
 
     Logs a user out, then redirects to the login page.
 
@@ -1189,24 +1171,15 @@ 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.
 
-    * ``current_app``: A hint indicating which application contains the current
-      view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
     * ``extra_context``: A dictionary of context data that will be added to the
       default context data passed to the template.
 
-    .. deprecated:: 1.9
-
-        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)
+.. function:: password_change(request, template_name='registration/password_change_form.html', post_change_redirect=None, password_change_form=PasswordChangeForm, extra_context=None)
 
     .. deprecated:: 1.11
 
@@ -1216,16 +1189,7 @@ implementation details see :ref:`using-the-views`.
     The optional arguments of this view are similar to the class-based
     ``PasswordChangeView`` attributes, except the ``post_change_redirect`` and
     ``password_change_form`` arguments which map to the ``success_url`` and
-    ``form_class`` attributes of the class-based view. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the current
-      view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` parameter is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``form_class`` attributes of the class-based view.
 
 .. class:: PasswordChangeView
 
@@ -1256,7 +1220,7 @@ implementation details see :ref:`using-the-views`.
 
     * ``form``: The password change form (see ``form_class`` above).
 
-.. function:: password_change_done(request, template_name='registration/password_change_done.html', current_app=None, extra_context=None)
+.. function:: password_change_done(request, template_name='registration/password_change_done.html', extra_context=None)
 
     .. deprecated:: 1.11
 
@@ -1264,16 +1228,7 @@ implementation details see :ref:`using-the-views`.
         the class-based :class:`PasswordChangeDoneView`.
 
     The optional arguments of this view are similar to the class-based
-    ``PasswordChangeDoneView`` attributes. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the current
-      view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` parameter is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``PasswordChangeDoneView`` attributes.
 
 .. class:: PasswordChangeDoneView
 
@@ -1292,7 +1247,7 @@ implementation details see :ref:`using-the-views`.
     * ``extra_context``: A dictionary of context data that will be added to the
       default context data passed to the template.
 
-.. function:: password_reset(request, template_name='registration/password_reset_form.html', email_template_name='registration/password_reset_email.html', subject_template_name='registration/password_reset_subject.txt', password_reset_form=PasswordResetForm, token_generator=default_token_generator, post_reset_redirect=None, from_email=None, current_app=None, extra_context=None, html_email_template_name=None, extra_email_context=None)
+.. function:: password_reset(request, template_name='registration/password_reset_form.html', email_template_name='registration/password_reset_email.html', subject_template_name='registration/password_reset_subject.txt', password_reset_form=PasswordResetForm, token_generator=default_token_generator, post_reset_redirect=None, from_email=None, extra_context=None, html_email_template_name=None, extra_email_context=None)
 
     .. deprecated:: 1.11
 
@@ -1302,16 +1257,7 @@ implementation details see :ref:`using-the-views`.
     The optional arguments of this view are similar to the class-based
     ``PasswordResetView`` attributes, except the ``post_reset_redirect`` and
     ``password_reset_form`` arguments which map to the ``success_url`` and
-    ``form_class`` attributes of the class-based view. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the current
-      view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` parameter is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``form_class`` attributes of the class-based view.
 
 .. class:: PasswordResetView
 
@@ -1413,7 +1359,7 @@ implementation details see :ref:`using-the-views`.
     The same template context is used for subject template. Subject must be
     single line plain text string.
 
-.. function:: password_reset_done(request, template_name='registration/password_reset_done.html', current_app=None, extra_context=None)
+.. function:: password_reset_done(request, template_name='registration/password_reset_done.html', extra_context=None)
 
     .. deprecated:: 1.11
 
@@ -1421,16 +1367,7 @@ implementation details see :ref:`using-the-views`.
         the  class-based :class:`PasswordResetDoneView`.
 
     The optional arguments of this view are similar to the class-based
-    ``PasswordResetDoneView`` attributes. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the current
-      view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` parameter is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``PasswordResetDoneView`` attributes.
 
 .. class:: PasswordResetDoneView
 
@@ -1457,7 +1394,7 @@ implementation details see :ref:`using-the-views`.
     * ``extra_context``: A dictionary of context data that will be added to the
       default context data passed to the template.
 
-.. function:: password_reset_confirm(request, uidb64=None, token=None, template_name='registration/password_reset_confirm.html', token_generator=default_token_generator, set_password_form=SetPasswordForm, post_reset_redirect=None, current_app=None, extra_context=None)
+.. function:: password_reset_confirm(request, uidb64=None, token=None, template_name='registration/password_reset_confirm.html', token_generator=default_token_generator, set_password_form=SetPasswordForm, post_reset_redirect=None, extra_context=None)
 
     .. deprecated:: 1.11
 
@@ -1467,16 +1404,7 @@ implementation details see :ref:`using-the-views`.
     The optional arguments of this view are similar to the class-based
     ``PasswordResetConfirmView`` attributes, except the ``post_reset_redirect``
     and ``set_password_form`` arguments which map to the ``success_url`` and
-    ``form_class`` attributes of the class-based view. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the current
-      view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` parameter is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``form_class`` attributes of the class-based view.
 
 .. class:: PasswordResetConfirmView
 
@@ -1523,7 +1451,7 @@ implementation details see :ref:`using-the-views`.
     * ``validlink``: Boolean, True if the link (combination of ``uidb64`` and
       ``token``) is valid or unused yet.
 
-.. function:: password_reset_complete(request, template_name='registration/password_reset_complete.html', current_app=None, extra_context=None)
+.. function:: password_reset_complete(request, template_name='registration/password_reset_complete.html', extra_context=None)
 
     .. deprecated:: 1.11
 
@@ -1531,16 +1459,7 @@ implementation details see :ref:`using-the-views`.
         by the class-based :class:`PasswordResetCompleteView`.
 
     The optional arguments of this view are similar to the class-based
-    ``PasswordResetCompleteView`` attributes. In addition, it has:
-
-    * ``current_app``: A hint indicating which application contains the current
-      view. See the :ref:`namespaced URL resolution strategy
-      <topics-http-reversing-url-namespaces>` for more information.
-
-    .. deprecated:: 1.9
-
-        The ``current_app`` parameter is deprecated and will be removed in
-        Django 2.0. Callers should set ``request.current_app`` instead.
+    ``PasswordResetCompleteView`` attributes.
 
 .. class:: PasswordResetCompleteView