mirror of https://github.com/django/django.git
Fixed #18511 -- Cleaned up admin password reset template titles.
This commit is contained in:
parent
8676318d2d
commit
e07e4030b9
|
@ -8,12 +8,8 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Password change successful' %}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h1>{% trans 'Password change successful' %}</h1>
|
|
||||||
|
|
||||||
<p>{% trans 'Your password was changed.' %}</p>
|
<p>{% trans 'Your password was changed.' %}</p>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Password change' %}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
|
||||||
|
|
||||||
{% block content %}<div id="content-main">
|
{% block content %}<div id="content-main">
|
||||||
|
|
||||||
|
@ -21,7 +22,6 @@
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h1>{% trans 'Password change' %}</h1>
|
|
||||||
|
|
||||||
<p>{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</p>
|
<p>{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</p>
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,11 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Password reset complete' %}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h1>{% trans 'Password reset complete' %}</h1>
|
|
||||||
|
|
||||||
<p>{% trans "Your password has been set. You may go ahead and log in now." %}</p>
|
<p>{% trans "Your password has been set. You may go ahead and log in now." %}</p>
|
||||||
|
|
||||||
<p><a href="{{ login_url }}">{% trans 'Log in' %}</a></p>
|
<p><a href="{{ login_url }}">{% trans 'Log in' %}</a></p>
|
||||||
|
|
|
@ -8,14 +8,12 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Password reset' %}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% if validlink %}
|
{% if validlink %}
|
||||||
|
|
||||||
<h1>{% trans 'Enter new password' %}</h1>
|
|
||||||
|
|
||||||
<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
|
<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
|
||||||
|
|
||||||
<form action="" method="post">{% csrf_token %}
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
@ -28,8 +26,6 @@
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<h1>{% trans 'Password reset unsuccessful' %}</h1>
|
|
||||||
|
|
||||||
<p>{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
|
<p>{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Password reset successful' %}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h1>{% trans 'Password reset successful' %}</h1>
|
|
||||||
|
|
||||||
<p>{% trans "We've emailed you instructions for setting your password. You should be receiving them shortly." %}</p>
|
<p>{% trans "We've emailed you instructions for setting your password. You should be receiving them shortly." %}</p>
|
||||||
|
|
||||||
<p>{% trans "If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder." %}</p>
|
<p>{% trans "If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder." %}</p>
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{% trans "Password reset" %}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h1>{% trans "Password reset" %}</h1>
|
|
||||||
|
|
||||||
<p>{% trans "Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one." %}</p>
|
<p>{% trans "Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one." %}</p>
|
||||||
|
|
||||||
<form action="" method="post">{% csrf_token %}
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
from django.contrib.auth import authenticate
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib.auth.tests.utils import skipIfCustomUser
|
||||||
|
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||||
|
from django.contrib.auth.views import (
|
||||||
|
password_reset, password_reset_done, password_reset_confirm,
|
||||||
|
password_reset_complete, password_change, password_change_done,
|
||||||
|
)
|
||||||
|
from django.test import RequestFactory, TestCase
|
||||||
|
from django.test.utils import override_settings
|
||||||
|
from django.utils.encoding import force_bytes, force_text
|
||||||
|
from django.utils.http import urlsafe_base64_encode
|
||||||
|
|
||||||
|
|
||||||
|
@skipIfCustomUser
|
||||||
|
@override_settings(
|
||||||
|
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
||||||
|
)
|
||||||
|
class AuthTemplateTests(TestCase):
|
||||||
|
|
||||||
|
def test_titles(self):
|
||||||
|
rf = RequestFactory()
|
||||||
|
user = User.objects.create_user('jsmith', 'jsmith@example.com', 'pass')
|
||||||
|
user = authenticate(username=user.username, password='pass')
|
||||||
|
request = rf.get('/somepath/')
|
||||||
|
request.user = user
|
||||||
|
|
||||||
|
response = password_reset(request, post_reset_redirect='dummy/')
|
||||||
|
self.assertContains(response, '<title>Password reset</title>')
|
||||||
|
self.assertContains(response, '<h1>Password reset</h1>')
|
||||||
|
|
||||||
|
response = password_reset_done(request)
|
||||||
|
self.assertContains(response, '<title>Password reset successful</title>')
|
||||||
|
self.assertContains(response, '<h1>Password reset successful</h1>')
|
||||||
|
|
||||||
|
# password_reset_confirm invalid token
|
||||||
|
response = password_reset_confirm(request, uidb64='Bad', token='Bad', post_reset_redirect='dummy/')
|
||||||
|
self.assertContains(response, '<title>Password reset unsuccessful</title>')
|
||||||
|
self.assertContains(response, '<h1>Password reset unsuccessful</h1>')
|
||||||
|
|
||||||
|
# password_reset_confirm valid token
|
||||||
|
default_token_generator = PasswordResetTokenGenerator()
|
||||||
|
token = default_token_generator.make_token(user)
|
||||||
|
uidb64 = force_text(urlsafe_base64_encode(force_bytes(user.pk)))
|
||||||
|
response = password_reset_confirm(request, uidb64, token, post_reset_redirect='dummy/')
|
||||||
|
self.assertContains(response, '<title>Enter new password</title>')
|
||||||
|
self.assertContains(response, '<h1>Enter new password</h1>')
|
||||||
|
|
||||||
|
response = password_reset_complete(request)
|
||||||
|
self.assertContains(response, '<title>Password reset complete</title>')
|
||||||
|
self.assertContains(response, '<h1>Password reset complete</h1>')
|
||||||
|
|
||||||
|
response = password_change(request, post_change_redirect='dummy/')
|
||||||
|
self.assertContains(response, '<title>Password change</title>')
|
||||||
|
self.assertContains(response, '<h1>Password change</h1>')
|
||||||
|
|
||||||
|
response = password_change_done(request)
|
||||||
|
self.assertContains(response, '<title>Password change successful</title>')
|
||||||
|
self.assertContains(response, '<h1>Password change successful</h1>')
|
|
@ -165,6 +165,7 @@ def password_reset(request, is_admin_site=False,
|
||||||
form = password_reset_form()
|
form = password_reset_form()
|
||||||
context = {
|
context = {
|
||||||
'form': form,
|
'form': form,
|
||||||
|
'title': _('Password reset'),
|
||||||
}
|
}
|
||||||
if extra_context is not None:
|
if extra_context is not None:
|
||||||
context.update(extra_context)
|
context.update(extra_context)
|
||||||
|
@ -175,7 +176,9 @@ def password_reset(request, is_admin_site=False,
|
||||||
def password_reset_done(request,
|
def password_reset_done(request,
|
||||||
template_name='registration/password_reset_done.html',
|
template_name='registration/password_reset_done.html',
|
||||||
current_app=None, extra_context=None):
|
current_app=None, extra_context=None):
|
||||||
context = {}
|
context = {
|
||||||
|
'title': _('Password reset successful'),
|
||||||
|
}
|
||||||
if extra_context is not None:
|
if extra_context is not None:
|
||||||
context.update(extra_context)
|
context.update(extra_context)
|
||||||
return TemplateResponse(request, template_name, context,
|
return TemplateResponse(request, template_name, context,
|
||||||
|
@ -209,6 +212,7 @@ def password_reset_confirm(request, uidb64=None, token=None,
|
||||||
|
|
||||||
if user is not None and token_generator.check_token(user, token):
|
if user is not None and token_generator.check_token(user, token):
|
||||||
validlink = True
|
validlink = True
|
||||||
|
title = _('Enter new password')
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = set_password_form(user, request.POST)
|
form = set_password_form(user, request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
@ -219,8 +223,10 @@ def password_reset_confirm(request, uidb64=None, token=None,
|
||||||
else:
|
else:
|
||||||
validlink = False
|
validlink = False
|
||||||
form = None
|
form = None
|
||||||
|
title = _('Password reset unsuccessful')
|
||||||
context = {
|
context = {
|
||||||
'form': form,
|
'form': form,
|
||||||
|
'title': title,
|
||||||
'validlink': validlink,
|
'validlink': validlink,
|
||||||
}
|
}
|
||||||
if extra_context is not None:
|
if extra_context is not None:
|
||||||
|
@ -232,7 +238,8 @@ def password_reset_complete(request,
|
||||||
template_name='registration/password_reset_complete.html',
|
template_name='registration/password_reset_complete.html',
|
||||||
current_app=None, extra_context=None):
|
current_app=None, extra_context=None):
|
||||||
context = {
|
context = {
|
||||||
'login_url': resolve_url(settings.LOGIN_URL)
|
'login_url': resolve_url(settings.LOGIN_URL),
|
||||||
|
'title': _('Password reset complete'),
|
||||||
}
|
}
|
||||||
if extra_context is not None:
|
if extra_context is not None:
|
||||||
context.update(extra_context)
|
context.update(extra_context)
|
||||||
|
@ -261,6 +268,7 @@ def password_change(request,
|
||||||
form = password_change_form(user=request.user)
|
form = password_change_form(user=request.user)
|
||||||
context = {
|
context = {
|
||||||
'form': form,
|
'form': form,
|
||||||
|
'title': _('Password change'),
|
||||||
}
|
}
|
||||||
if extra_context is not None:
|
if extra_context is not None:
|
||||||
context.update(extra_context)
|
context.update(extra_context)
|
||||||
|
@ -272,7 +280,9 @@ def password_change(request,
|
||||||
def password_change_done(request,
|
def password_change_done(request,
|
||||||
template_name='registration/password_change_done.html',
|
template_name='registration/password_change_done.html',
|
||||||
current_app=None, extra_context=None):
|
current_app=None, extra_context=None):
|
||||||
context = {}
|
context = {
|
||||||
|
'title': _('Password change successful'),
|
||||||
|
}
|
||||||
if extra_context is not None:
|
if extra_context is not None:
|
||||||
context.update(extra_context)
|
context.update(extra_context)
|
||||||
return TemplateResponse(request, template_name, context,
|
return TemplateResponse(request, template_name, context,
|
||||||
|
|
Loading…
Reference in New Issue