Refs #21648 -- Removed is_admin_site option from password_reset() view.
Per deprecation timeline.
This commit is contained in:
parent
fd6a299cd0
commit
f1761e3fef
|
@ -17,9 +17,7 @@ from django.core.urlresolvers import reverse
|
|||
from django.http import HttpResponseRedirect, QueryDict
|
||||
from django.shortcuts import resolve_url
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.deprecation import (
|
||||
RemovedInDjango20Warning, RemovedInDjango110Warning,
|
||||
)
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
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
|
||||
|
@ -166,7 +164,7 @@ def redirect_to_login(next, login_url=None,
|
|||
|
||||
@deprecate_current_app
|
||||
@csrf_protect
|
||||
def password_reset(request, is_admin_site=False,
|
||||
def 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',
|
||||
|
@ -194,14 +192,6 @@ def password_reset(request, is_admin_site=False,
|
|||
'html_email_template_name': html_email_template_name,
|
||||
'extra_email_context': extra_email_context,
|
||||
}
|
||||
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 1.10.",
|
||||
RemovedInDjango110Warning, 3
|
||||
)
|
||||
opts = dict(opts, domain_override=request.get_host())
|
||||
form.save(**opts)
|
||||
return HttpResponseRedirect(post_reset_redirect)
|
||||
else:
|
||||
|
|
|
@ -1219,7 +1219,7 @@ 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.
|
||||
|
||||
.. function:: password_reset(request, is_admin_site=False, 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, current_app=None, extra_context=None, html_email_template_name=None, extra_email_context=None)
|
||||
|
||||
Allows a user to reset their password by generating a one-time use link
|
||||
that can be used to reset the password, and sending that link to the
|
||||
|
@ -1283,11 +1283,6 @@ implementation details see :ref:`using-the-views`.
|
|||
* ``extra_email_context``: A dictionary of context data that will available
|
||||
in the email template.
|
||||
|
||||
.. deprecated:: 1.8
|
||||
|
||||
The ``is_admin_site`` argument is deprecated and will be removed in
|
||||
Django 1.10.
|
||||
|
||||
.. deprecated:: 1.9
|
||||
|
||||
The ``current_app`` parameter is deprecated and will be removed in
|
||||
|
|
|
@ -24,11 +24,8 @@ from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy
|
|||
from django.db import connection
|
||||
from django.http import HttpRequest, QueryDict
|
||||
from django.middleware.csrf import CsrfViewMiddleware, get_token
|
||||
from django.test import (
|
||||
TestCase, ignore_warnings, modify_settings, override_settings,
|
||||
)
|
||||
from django.test import TestCase, modify_settings, override_settings
|
||||
from django.test.utils import patch_logger
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.http import urlquote
|
||||
from django.utils.six.moves.urllib.parse import ParseResult, urlparse
|
||||
|
@ -209,19 +206,6 @@ class PasswordResetTest(AuthViewsTestCase):
|
|||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertEqual("staffmember@example.com", mail.outbox[0].from_email)
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango110Warning)
|
||||
@override_settings(ALLOWED_HOSTS=['adminsite.com'])
|
||||
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."
|
||||
response = self.client.post('/admin_password_reset/',
|
||||
{'email': 'staffmember@example.com'},
|
||||
HTTP_HOST='adminsite.com'
|
||||
)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertIn("http://adminsite.com", mail.outbox[0].body)
|
||||
self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
|
||||
|
||||
# Skip any 500 handler action (like sending more mail...)
|
||||
@override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True)
|
||||
def test_poisoned_http_host(self):
|
||||
|
|
|
@ -85,7 +85,6 @@ urlpatterns = auth_urlpatterns + [
|
|||
dict(post_reset_redirect='password_reset')),
|
||||
url(r'^password_change/custom/$', views.password_change, dict(post_change_redirect='/custom/')),
|
||||
url(r'^password_change/custom/named/$', views.password_change, dict(post_change_redirect='password_reset')),
|
||||
url(r'^admin_password_reset/$', views.password_reset, dict(is_admin_site=True)),
|
||||
url(r'^login_required/$', login_required(views.password_reset)),
|
||||
url(r'^login_required_login_url/$', login_required(views.password_reset, login_url='/somewhere/')),
|
||||
|
||||
|
|
Loading…
Reference in New Issue