From 49ddbaae9005c5d8eb5c22d043fd280ff8186ff3 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 3 Feb 2014 15:15:35 +0000 Subject: [PATCH] merge 002b896e45b48c5ca80c3ed3cb8f4a2f921f8af8 (allow password management to be enabled/disabled by the WAGTAIL_PASSWORD_MANAGEMENT_ENABLED setting). Need to apply manually because git chokes on the lack of submodules on the feature/user-account-settings branch. --- .../wagtailadmin/account/account.html | 18 ++++++++++-------- .../templates/wagtailadmin/login.html | 4 +++- wagtail/wagtailadmin/urls.py | 7 ++++++- wagtail/wagtailadmin/views/account.py | 5 ++++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/account.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/account.html index 92fb8f585e..93326b3ac7 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/account/account.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/account.html @@ -17,15 +17,17 @@ -
  • - + {% if show_change_password %} +
  • + - - Change the password you use to log in. - -
  • + + Change the password you use to log in. + + + {% endif %} {% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/login.html b/wagtail/wagtailadmin/templates/wagtailadmin/login.html index d902dd586e..31c087942e 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/login.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/login.html @@ -36,7 +36,9 @@ {{ form.password.label_tag }} {{ form.password }} -

    Forgotten it?

    + {% if show_password_reset %} +

    Forgotten it?

    + {% endif %} {% comment %} Removed until functionality exists diff --git a/wagtail/wagtailadmin/urls.py b/wagtail/wagtailadmin/urls.py index ae0979d13c..8690f6a636 100644 --- a/wagtail/wagtailadmin/urls.py +++ b/wagtail/wagtailadmin/urls.py @@ -1,8 +1,13 @@ from django.conf.urls import patterns, url +from django.conf import settings from wagtail.wagtailadmin.forms import LoginForm, PasswordResetForm urlpatterns = patterns('django.contrib.auth.views', - url(r'^login/$', 'login', {'template_name': 'wagtailadmin/login.html', 'authentication_form': LoginForm}), + url(r'^login/$', 'login', { + 'template_name': 'wagtailadmin/login.html', + 'authentication_form': LoginForm, + 'extra_context': {'show_password_reset': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True)}, + }), url(r'^logout/$', 'logout', {'next_page': '/admin/login/'}), # Password reset diff --git a/wagtail/wagtailadmin/views/account.py b/wagtail/wagtailadmin/views/account.py index cc05156979..dccbf2d459 100644 --- a/wagtail/wagtailadmin/views/account.py +++ b/wagtail/wagtailadmin/views/account.py @@ -1,10 +1,13 @@ +from django.conf import settings from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.forms import SetPasswordForm def account(request): - return render(request, 'wagtailadmin/account/account.html') + return render(request, 'wagtailadmin/account/account.html', { + 'show_change_password': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True) and request.user.has_usable_password(), + }) def change_password(request):