Fixed #21648 -- Deprecated is_admin_site option to auth.views.password_reset().
This commit is contained in:
parent
0c9f40f776
commit
e39af5ea59
|
@ -2,6 +2,7 @@ from importlib import import_module
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import warnings
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import global_settings, settings
|
from django.conf import global_settings, settings
|
||||||
|
@ -160,6 +161,8 @@ class PasswordResetTest(AuthViewsTestCase):
|
||||||
@override_settings(ALLOWED_HOSTS=['adminsite.com'])
|
@override_settings(ALLOWED_HOSTS=['adminsite.com'])
|
||||||
def test_admin_reset(self):
|
def test_admin_reset(self):
|
||||||
"If the reset view is marked as being for admin, the HTTP_HOST header is used for a domain override."
|
"If the reset view is marked as being for admin, the HTTP_HOST header is used for a domain override."
|
||||||
|
with warnings.catch_warnings(record=True):
|
||||||
|
warnings.simplefilter("always")
|
||||||
response = self.client.post('/admin_password_reset/',
|
response = self.client.post('/admin_password_reset/',
|
||||||
{'email': 'staffmember@example.com'},
|
{'email': 'staffmember@example.com'},
|
||||||
HTTP_HOST='adminsite.com'
|
HTTP_HOST='adminsite.com'
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
import warnings
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponseRedirect, QueryDict
|
from django.http import HttpResponseRedirect, QueryDict
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
from django.utils.deprecation import RemovedInDjango20Warning
|
||||||
from django.utils.http import is_safe_url, urlsafe_base64_decode
|
from django.utils.http import is_safe_url, urlsafe_base64_decode
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.utils.six.moves.urllib.parse import urlparse, urlunparse
|
from django.utils.six.moves.urllib.parse import urlparse, urlunparse
|
||||||
|
@ -159,6 +162,12 @@ def password_reset(request, is_admin_site=False,
|
||||||
'html_email_template_name': html_email_template_name,
|
'html_email_template_name': html_email_template_name,
|
||||||
}
|
}
|
||||||
if is_admin_site:
|
if is_admin_site:
|
||||||
|
warnings.warn(
|
||||||
|
"The is_admin_site argument to "
|
||||||
|
"django.contrib.auth.views.password_reset() is deprecated "
|
||||||
|
"and will be removed in Django 2.0.",
|
||||||
|
RemovedInDjango20Warning, 3
|
||||||
|
)
|
||||||
opts = dict(opts, domain_override=request.get_host())
|
opts = dict(opts, domain_override=request.get_host())
|
||||||
form.save(**opts)
|
form.save(**opts)
|
||||||
return HttpResponseRedirect(post_reset_redirect)
|
return HttpResponseRedirect(post_reset_redirect)
|
||||||
|
|
|
@ -54,6 +54,9 @@ about each item can often be found in the release notes of two versions prior.
|
||||||
* The ``remove_tags()`` and ``strip_entities()`` functions in
|
* The ``remove_tags()`` and ``strip_entities()`` functions in
|
||||||
``django.utils.html`` will be removed.
|
``django.utils.html`` will be removed.
|
||||||
|
|
||||||
|
* The ``is_admin_site`` argument to
|
||||||
|
``django.contrib.auth.views.password_reset()`` will be removed.
|
||||||
|
|
||||||
.. _deprecation-removed-in-1.9:
|
.. _deprecation-removed-in-1.9:
|
||||||
|
|
||||||
1.9
|
1.9
|
||||||
|
|
|
@ -708,3 +708,8 @@ they are not actually safe.
|
||||||
|
|
||||||
The unused and undocumented ``django.utils.html.strip_entities()`` function has
|
The unused and undocumented ``django.utils.html.strip_entities()`` function has
|
||||||
also been deprecated.
|
also been deprecated.
|
||||||
|
|
||||||
|
``is_admin_site`` argument to ``django.contrib.auth.views.password_reset()``
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
It's a legacy option that should no longer be necessary.
|
||||||
|
|
|
@ -984,6 +984,11 @@ patterns.
|
||||||
|
|
||||||
``html_email_template_name`` was added.
|
``html_email_template_name`` was added.
|
||||||
|
|
||||||
|
.. deprecated:: 1.8
|
||||||
|
|
||||||
|
The ``is_admin_site`` argument is deprecated and will be removed in
|
||||||
|
Django 2.0.
|
||||||
|
|
||||||
**Template context:**
|
**Template context:**
|
||||||
|
|
||||||
* ``form``: The form (see ``password_reset_form`` above) for resetting
|
* ``form``: The form (see ``password_reset_form`` above) for resetting
|
||||||
|
|
Loading…
Reference in New Issue