diff options
| author | Tim Graham <timograham@gmail.com> | 2014-08-18 10:36:51 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-08-23 19:32:58 -0400 |
| commit | e39af5ea592bbe4e7a643e67f0c379adc10ed392 (patch) | |
| tree | f3327e152fe72dd01ab86272013124f8b1a6e648 /django | |
| parent | 0c9f40f776e2be75656996e1bb1e5f37f903675f (diff) | |
Fixed #21648 -- Deprecated is_admin_site option to auth.views.password_reset().
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/tests/test_views.py | 11 | ||||
| -rw-r--r-- | django/contrib/auth/views.py | 9 |
2 files changed, 16 insertions, 4 deletions
diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py index dcfda61ca9..710324b2a1 100644 --- a/django/contrib/auth/tests/test_views.py +++ b/django/contrib/auth/tests/test_views.py @@ -2,6 +2,7 @@ from importlib import import_module import itertools import os import re +import warnings from django.apps import apps from django.conf import global_settings, settings @@ -160,10 +161,12 @@ class PasswordResetTest(AuthViewsTestCase): @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' - ) + with warnings.catch_warnings(record=True): + warnings.simplefilter("always") + 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.assertTrue("http://adminsite.com" in mail.outbox[0].body) diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index 969ab810d8..4d2543a461 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -1,7 +1,10 @@ +import warnings + from django.conf import settings from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, QueryDict 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.translation import ugettext as _ 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, } 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()) form.save(**opts) return HttpResponseRedirect(post_reset_redirect) |
