From b779ecaf1477aa48b52b986d18bc2e418cf80d48 Mon Sep 17 00:00:00 2001 From: Aarni Halinen Date: Tue, 31 Oct 2017 19:05:13 +0200 Subject: [PATCH] Add password recovery tool All templates overridden for easier custom texts. Login_base.html for recovery and login pages --- sikweb/base.py | 1 + sikweb/urls.py | 2 + templates/login.html | 35 +++++++++++++++ templates/login_base.html | 38 ++++++++++++++++ templates/password_reset/base.html | 1 + templates/password_reset/recovery_done.html | 8 ++++ templates/password_reset/recovery_form.html | 12 +++++ templates/password_reset/reset.html | 14 ++++++ templates/password_reset/reset_mail.html | 15 +++++++ templates/password_reset/reset_sent.html | 8 ++++ webapp/templates/login.html | 49 --------------------- 11 files changed, 134 insertions(+), 49 deletions(-) create mode 100644 templates/login.html create mode 100644 templates/login_base.html create mode 100644 templates/password_reset/base.html create mode 100644 templates/password_reset/recovery_done.html create mode 100644 templates/password_reset/recovery_form.html create mode 100644 templates/password_reset/reset.html create mode 100644 templates/password_reset/reset_mail.html create mode 100644 templates/password_reset/reset_sent.html delete mode 100644 webapp/templates/login.html diff --git a/sikweb/base.py b/sikweb/base.py index c094344..ebd88c6 100644 --- a/sikweb/base.py +++ b/sikweb/base.py @@ -85,6 +85,7 @@ INSTALLED_APPS = [ 'django_tables2', 'auditlog', 'phonenumber_field', + 'password_reset', ] TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' diff --git a/sikweb/urls.py b/sikweb/urls.py index 2e0793c..ade52f0 100644 --- a/sikweb/urls.py +++ b/sikweb/urls.py @@ -26,6 +26,7 @@ import webapp.urls import infoscreen.urls import members.urls import coffee_scale.urls +import password_reset.urls urlpatterns = [ url(r'', include('webapp.urls')), @@ -35,6 +36,7 @@ urlpatterns = [ # admin url(r'^admin/', admin.site.urls), + url(r'^reset/', include('password_reset.urls')), # i18n default view for changing the active language url(r'^i18n/', include('django.conf.urls.i18n')), diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..948c0f8 --- /dev/null +++ b/templates/login.html @@ -0,0 +1,35 @@ +{% extends "login_base.html" %} +{% load i18n %} + +{% block content %} +

SIK Admin

+
{% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
{{ error }}
+
+
+
+
+ +
+
+
+{% endblock content %} diff --git a/templates/login_base.html b/templates/login_base.html new file mode 100644 index 0000000..1aa3b9e --- /dev/null +++ b/templates/login_base.html @@ -0,0 +1,38 @@ + + +{% load i18n %} +{% load static %} + + + + SIK - Login + + + + + + + + + + + + + {% block header %} +
+ {% include "sik_header.html" %} +
+ {% endblock %} + +
+ {% block content %} + {% endblock %} +
+ + + + \ No newline at end of file diff --git a/templates/password_reset/base.html b/templates/password_reset/base.html new file mode 100644 index 0000000..75aebfd --- /dev/null +++ b/templates/password_reset/base.html @@ -0,0 +1 @@ +{% extends "login_base.html" %} \ No newline at end of file diff --git a/templates/password_reset/recovery_done.html b/templates/password_reset/recovery_done.html new file mode 100644 index 0000000..164b8ff --- /dev/null +++ b/templates/password_reset/recovery_done.html @@ -0,0 +1,8 @@ +{% extends "password_reset/base.html" %}{% load i18n %} + +{% block title %}{% trans "New password set" %}{% endblock %} + +{% block content %} +

{% trans "Your password has successfully been reset. You can use it right now on the login page." %}

+

Log in

+{% endblock %} \ No newline at end of file diff --git a/templates/password_reset/recovery_form.html b/templates/password_reset/recovery_form.html new file mode 100644 index 0000000..1dec151 --- /dev/null +++ b/templates/password_reset/recovery_form.html @@ -0,0 +1,12 @@ +{% extends "password_reset/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Password recovery" %}{% endblock %} + +{% block content %} +
+ {% csrf_token %} + {{ form.as_p }} +

+
+{% endblock %} \ No newline at end of file diff --git a/templates/password_reset/reset.html b/templates/password_reset/reset.html new file mode 100644 index 0000000..ab1cd5c --- /dev/null +++ b/templates/password_reset/reset.html @@ -0,0 +1,14 @@ +{% extends "password_reset/base.html" %}{% load i18n %} + +{% block content %} + {% if invalid %}{% url "password_reset_recover" as recovery_url %} +

{% blocktrans %}Sorry, this password reset link is invalid. You can still request a new one.{% endblocktrans %}

+ {% else %} +

{% blocktrans %}Hi, {{ username }}. Please choose your new password.{% endblocktrans %}

+
+ {% csrf_token %} + {{ form.as_p }} +

+
+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/password_reset/reset_mail.html b/templates/password_reset/reset_mail.html new file mode 100644 index 0000000..c1ef31f --- /dev/null +++ b/templates/password_reset/reset_mail.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 uidb36=uid, token=token %} +{% endblock %} + +Your username, in case you've forgotten: {{ user.username }} + +Thanks for using our site! + +The {{ site_name }} team. + +{% endautoescape %} \ No newline at end of file diff --git a/templates/password_reset/reset_sent.html b/templates/password_reset/reset_sent.html new file mode 100644 index 0000000..15d12d7 --- /dev/null +++ b/templates/password_reset/reset_sent.html @@ -0,0 +1,8 @@ +{% extends "password_reset/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Password recovery sent" %}{% endblock %} + +{% block content %} +

{% blocktrans with ago=timestamp|timesince %}An email was sent to {{ email }} {{ ago }} ago. Use the link in it to set a new password.{% endblocktrans %}

+{% endblock %} \ No newline at end of file diff --git a/webapp/templates/login.html b/webapp/templates/login.html deleted file mode 100644 index 7d2d763..0000000 --- a/webapp/templates/login.html +++ /dev/null @@ -1,49 +0,0 @@ - - -{% load i18n %} -{% load static %} - - - - SIK - Login - - - - - - - - - - - - -
-

SIK Admin

-
{% csrf_token %} -
- -
- -
-
-
- -
- -
-
-
-
-
{{ error }}
-
-
-
-
- -
-
-
-
- -