From ca5708cf01c7e840d3621715dd2df8fda8c26676 Mon Sep 17 00:00:00 2001 From: macartur Date: Thu, 9 Oct 2014 12:18:14 -0300 Subject: [PATCH] Custom Password Reset templates --- colab/accounts/urls.py | 19 +++++++++---------- colab/accounts/views.py | 16 +++++++++++++++- src/accounts/templates/registration/login.html | 1 - src/accounts/templates/registration/password_change.html | 56 -------------------------------------------------------- src/accounts/templates/registration/password_change_form_custom.html | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/accounts/templates/registration/password_reset_complete_custom.html | 8 ++++++++ src/accounts/templates/registration/password_reset_confirm_custom.html | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/accounts/templates/registration/password_reset_done_custom.html | 8 ++++++++ src/accounts/templates/registration/password_reset_email_custom.html | 15 +++++++++++++++ src/accounts/templates/registration/password_reset_form_custom.html | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 232 insertions(+), 68 deletions(-) delete mode 100644 src/accounts/templates/registration/password_change.html create mode 100644 src/accounts/templates/registration/password_change_form_custom.html create mode 100644 src/accounts/templates/registration/password_reset_complete_custom.html create mode 100644 src/accounts/templates/registration/password_reset_confirm_custom.html create mode 100644 src/accounts/templates/registration/password_reset_done_custom.html create mode 100644 src/accounts/templates/registration/password_reset_email_custom.html create mode 100644 src/accounts/templates/registration/password_reset_form_custom.html diff --git a/colab/accounts/urls.py b/colab/accounts/urls.py index 91b5604..acb9c29 100644 --- a/colab/accounts/urls.py +++ b/colab/accounts/urls.py @@ -10,24 +10,23 @@ from django.contrib.auth import views as auth_views urlpatterns = patterns('', url(r'^register/$', 'colab.accounts.views.signup', name='signup'), - url(r'^password-reset-done/?$', - 'django.contrib.auth.views.password_reset_done', + url(r'^password-reset-done/?$', 'accounts.views.password_reset_done_custom', name="password_reset_done"), - url(r'^password-reset-complete/$', - 'django.contrib.auth.views.password_reset_complete', + url(r'^password-reset-complete/$', 'accounts.views.password_reset_complete_custom', name="password_reset_complete"), url(r'^password-reset-confirm/(?P[0-9A-Za-z]+)-(?P.+)/$', - 'django.contrib.auth.views.password_reset_confirm', + auth_views.password_reset_confirm, + {'template_name':'registration/password_reset_confirm_custom.html'}, name="password_reset_confirm"), - url(r'^password-reset/?$', - 'django.contrib.auth.views.password_reset', name="password_reset"), + url(r'^password-reset/?$', auth_views.password_reset, + {'template_name':'registration/password_reset_form_custom.html'}, + name="password_reset"), - url(r'^change-password/?$', - auth_views.password_change, - {'template_name': 'registration/password_change.html'}, + url(r'^change-password/?$',auth_views.password_change, + {'template_name':'registration/password_change_form_custom.html'}, name='password_change'), url(r'^change-password-done/?$', diff --git a/colab/accounts/views.py b/colab/accounts/views.py index d677aac..021b102 100644 --- a/colab/accounts/views.py +++ b/colab/accounts/views.py @@ -277,8 +277,22 @@ class ChangeXMPPPasswordView(UpdateView): return response def password_changed(request): - messages.success(request, _('Your password has been updated!')) + #FIXME: This message was not translated yet. + messages.success(request, _('Your password was changed.')) user = request.user return redirect('user_profile_update', username=user.username) + +def password_reset_done_custom(request): + messages.success(request, _('We\'ve emailed you instructions for setting your password. You should be receiving them shortly.')) + + return redirect('home') + +def password_reset_complete_custom(request): + #FIXME: This message was not translated yet. + messages.success(request, _('Your password has been set. You may go ahead and log in now.')) + + return redirect('home') + + diff --git a/src/accounts/templates/registration/login.html b/src/accounts/templates/registration/login.html index 3ef7278..16a694a 100644 --- a/src/accounts/templates/registration/login.html +++ b/src/accounts/templates/registration/login.html @@ -1,4 +1,3 @@ - {% extends "base.html" %} {% load i18n %} {% block main-content %} diff --git a/src/accounts/templates/registration/password_change.html b/src/accounts/templates/registration/password_change.html deleted file mode 100644 index 3b662bf..0000000 --- a/src/accounts/templates/registration/password_change.html +++ /dev/null @@ -1,56 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block main-content %} - -
- {% if form.errors %} -
- - {% if form.errors.items|length == 1 %}{% trans "Please correct the error below and try again." %}{% else %}{% trans "Please correct the errors below and try again." %}{% endif %} - -
- {% endif %} -
- -
- - -{% endblock %} diff --git a/src/accounts/templates/registration/password_change_form_custom.html b/src/accounts/templates/registration/password_change_form_custom.html new file mode 100644 index 0000000..7cdefc8 --- /dev/null +++ b/src/accounts/templates/registration/password_change_form_custom.html @@ -0,0 +1,61 @@ +{% extends "base.html" %} +{% load i18n %} +{% block main-content %} + +
+ {% if form.errors %} +
+ + {% if form.errors.items|length == 1 %} + + {% trans "Please correct the error below and try again." %} + {% else %} + {% trans "Please correct the errors below and try again." %} + {% endif %} + +
+ {% endif %} +
+ +
+ + +{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_complete_custom.html b/src/accounts/templates/registration/password_reset_complete_custom.html new file mode 100644 index 0000000..e115899 --- /dev/null +++ b/src/accounts/templates/registration/password_reset_complete_custom.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block title %}Password reset complete{% endblock %} + +{% block main-content %} +

Your password has been set. You may go ahead and log in now.

+

Log in

+{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_confirm_custom.html b/src/accounts/templates/registration/password_reset_confirm_custom.html new file mode 100644 index 0000000..d7e267d --- /dev/null +++ b/src/accounts/templates/registration/password_reset_confirm_custom.html @@ -0,0 +1,64 @@ +{% extends "base.html" %} +{% load i18n %} +{% block title %}{% trans "Setting New password" %}{% endblock %} +{% block main-content %} + {% if validlink %} + +
+ {% if form.errors %} +
+ + {% if form.errors.items|length == 1 %} + {% trans "Please correct the error below and try again." %} + {% else %} + + {% trans "Please correct the errors below and try again." %} + {% endif %} + +
+ {% endif %} +
+ +
+ + {% else %} +

Password reset unsuccessful

+

The password reset link was invalid,
+ possibly because it has already been used.
+ Please request a new password reset.

+ {% endif %} + +{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_done_custom.html b/src/accounts/templates/registration/password_reset_done_custom.html new file mode 100644 index 0000000..fac48c0 --- /dev/null +++ b/src/accounts/templates/registration/password_reset_done_custom.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block title %}Password reset successful{% endblock %} + +{% block main-content %} +

We've e-mailed you instructions for setting your password to the e-mail address you submitted.

+

You should be receiving it shortly.

+{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_email_custom.html b/src/accounts/templates/registration/password_reset_email_custom.html new file mode 100644 index 0000000..1c712cf --- /dev/null +++ b/src/accounts/templates/registration/password_reset_email_custom.html @@ -0,0 +1,15 @@ +{% autoescape off %} +You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}. + +Please go to the following page and choose a new password: +{% block reset_link %} +{{ protocol }}://{{ domain }}{% url django.contrib.auth.views.password_reset_confirm uidb64=uid, token=token %} +{% endblock %} + +Your username, in case you've forgotten: {{ user.username }} + +Thanks for using our site! + +The {{ site_name }} team. + +{% endautoescape %} diff --git a/src/accounts/templates/registration/password_reset_form_custom.html b/src/accounts/templates/registration/password_reset_form_custom.html new file mode 100644 index 0000000..359478a --- /dev/null +++ b/src/accounts/templates/registration/password_reset_form_custom.html @@ -0,0 +1,52 @@ +{% extends "base.html" %} +{% load i18n %} +{% block main-content %} + + +
+ {% if form.errors %} +
+ {% trans "Please correct the errors below and try again" %} +
+ {% endif %} +
+ +
+ + +{% endblock %} + + + + + + + + + -- libgit2 0.21.2