From e166ea9dd833f5d22f8a32d36fd4ed539c902410 Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Sat, 26 Apr 2014 23:57:55 +0800 Subject: * implemented 'password_reset' function based on django auth views * added password_reset related templates and email templates * updated account urls.py --- account/templates/account/login.html | 3 ++ .../templates/account/password_reset_complete.html | 20 +++++++++ .../templates/account/password_reset_confirm.html | 36 ++++++++++++++++ account/templates/account/password_reset_done.html | 20 +++++++++ .../templates/account/password_reset_email.html | 12 ++++++ account/templates/account/password_reset_form.html | 25 +++++++++++ .../templates/account/password_reset_subject.txt | 1 + account/urls.py | 50 +++++++++++++++------- 8 files changed, 152 insertions(+), 15 deletions(-) create mode 100644 account/templates/account/password_reset_complete.html create mode 100644 account/templates/account/password_reset_confirm.html create mode 100644 account/templates/account/password_reset_done.html create mode 100644 account/templates/account/password_reset_email.html create mode 100644 account/templates/account/password_reset_form.html create mode 100644 account/templates/account/password_reset_subject.txt (limited to 'account') diff --git a/account/templates/account/login.html b/account/templates/account/login.html index 4fee972..fb14550 100644 --- a/account/templates/account/login.html +++ b/account/templates/account/login.html @@ -18,6 +18,9 @@ {% bootstrap_form form layout='horizontal' %} {% buttons submit='提交' reset='重置' layout='horizontal' %}{% endbuttons %} + +
+

忘记密码了? 重置密码

{% endblock %} diff --git a/account/templates/account/password_reset_complete.html b/account/templates/account/password_reset_complete.html new file mode 100644 index 0000000..f4705e9 --- /dev/null +++ b/account/templates/account/password_reset_complete.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% load url from future %} +{% load bootstrap3 %} + +{# step4: password reset complete template #} + +{% block title %} +成功设置新密码 | 2014 SKA Summer School +{% endblock %} + +{% block content %} +
+

成功设置新密码

+
+

您已成功设置了新的登录密码。 登录

+
+{% endblock %} + +{# vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=htmldjango.html: #} diff --git a/account/templates/account/password_reset_confirm.html b/account/templates/account/password_reset_confirm.html new file mode 100644 index 0000000..2ae2711 --- /dev/null +++ b/account/templates/account/password_reset_confirm.html @@ -0,0 +1,36 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% load url from future %} +{% load bootstrap3 %} + +{# step3: password reset confirm template #} + +{% block title %} +{% if validlink %} +设置新密码 | 2014 SKA Summer School +{% else %} +重置密码失败 | 2014 SKA Summer School +{% endif %} +{% endblock %} + +{% block content %} +
+ {% if validlink %} +

设置新密码

+
+

请在以下为您的账户设置新登录密码。

+
+ {% csrf_token %} + {% bootstrap_form form layout='horizontal' %} + {% buttons submit='提交' reset='重置' layout='horizontal' %}{% endbuttons %} +
+ {% else %} +

重置密码失败

+
+

很抱歉,您使用的链接无效,可能该链接已被使用过,您可以尝试重新请求重置密码。

+

如果仍有问题,请与我们联系:skaschool2014@163.com

+ {% endif %} +
+{% endblock %} + +{# vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=htmldjango.html: #} diff --git a/account/templates/account/password_reset_done.html b/account/templates/account/password_reset_done.html new file mode 100644 index 0000000..98c513b --- /dev/null +++ b/account/templates/account/password_reset_done.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% load url from future %} +{% load bootstrap3 %} + +{# step2: password reset done template #} + +{% block title %} +已发送重置邮件 | 2014 SKA Summer School +{% endblock %} + +{% block content %} +
+

已发送重置邮件

+

我们已经向您的邮件发送了重置密码邮件,请留意查收,并使用其中的链接重置密码。

+

如果您未能收到邮件,请确认是否正确输入您当时注册使用的邮箱。如果仍有问题,请与我们联系:skaschool2014@163.com

+
+{% endblock %} + +{# vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=htmldjango.html: #} diff --git a/account/templates/account/password_reset_email.html b/account/templates/account/password_reset_email.html new file mode 100644 index 0000000..7ea9da6 --- /dev/null +++ b/account/templates/account/password_reset_email.html @@ -0,0 +1,12 @@ +Hello, + +您收到这封邮件是因为您请求重置您在网站 {{ site_name }} (2014 SKA Summer School)上的账户密码。 + +请打开以下链接来重新设置新密码: + +{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} + +您的登录用户名为:{{ user.get_username }} + + +2014 SKA Summer School Team diff --git a/account/templates/account/password_reset_form.html b/account/templates/account/password_reset_form.html new file mode 100644 index 0000000..ec8491d --- /dev/null +++ b/account/templates/account/password_reset_form.html @@ -0,0 +1,25 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% load url from future %} +{% load bootstrap3 %} + +{# step1: password reset template #} + +{% block title %} +重置密码 | 2014 SKA Summer School +{% endblock %} + +{% block content %} +
+

重置密码

+
+

请在下面输入您注册时使用的邮箱地址,然后我们将发送邮件以帮助您重新设置密码。

+
+ {% csrf_token %} + {% bootstrap_form form layout='horizontal' %} + {% buttons submit='提交' layout='horizontal' %}{% endbuttons %} +
+
+{% endblock %} + +{# vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=htmldjango.html: #} diff --git a/account/templates/account/password_reset_subject.txt b/account/templates/account/password_reset_subject.txt new file mode 100644 index 0000000..e36ec12 --- /dev/null +++ b/account/templates/account/password_reset_subject.txt @@ -0,0 +1 @@ +重置您的账户密码 diff --git a/account/urls.py b/account/urls.py index b17abd5..ea6977b 100644 --- a/account/urls.py +++ b/account/urls.py @@ -29,15 +29,6 @@ urlpatterns = patterns('', url(r'^profile/update/done/$', login_required(TemplateView.as_view(template_name='account/profile_update_done.html')), name='profile_update_done'), - ## django auth views - # login - url(r'^login/$', 'django.contrib.auth.views.login', - {'template_name': 'account/login.html'}, - name='login'), - # logout - url(r'^logout/$', 'django.contrib.auth.views.logout', - {'template_name': 'account/logout.html'}, - name='logout'), # resend activate email url(r'^email/resend/$', ResendEmailView.as_view(), @@ -46,19 +37,48 @@ urlpatterns = patterns('', url(r'^email/resend/done/$', TemplateView.as_view(template_name='account/email_resend_done.html'), name='email_resend_done'), - # change password + ## show approved user list + url(r'^list/approved/$', login_required(ListApprovedView.as_view()), + name='list_approved'), +) + +urlpatterns += patterns('django.contrib.auth.views', + ## django auth views + # login + url(r'^login/$', 'login', + {'template_name': 'account/login.html'}, + name='login'), + # logout + url(r'^logout/$', 'logout', + {'template_name': 'account/logout.html'}, + name='logout'), + ## change password # If 'post_change_redirect' not provided, # then redirect to url 'password_change_done'. - url(r'^password/change/$', 'django.contrib.auth.views.password_change', + url(r'^password/change/$', 'password_change', {'template_name': 'account/password_change.html'}, name='password_change'), # change password done - url(r'^password/change/done$', 'django.contrib.auth.views.password_change_done', + url(r'^password/change/done$', 'password_change_done', {'template_name': 'account/password_change_done.html'}, name='password_change_done'), - ## show approved user list - url(r'^list/approved/$', login_required(ListApprovedView.as_view()), - name='list_approved'), + ## reset password + url(r'^password/reset/$', 'password_reset', + {'template_name': 'account/password_reset_form.html'}, + name='password_reset'), + # reset password done + url(r'^password/reset/done/$', 'password_reset_done', + {'template_name': 'account/password_reset_done.html'}, + name='password_reset_done'), + # reset password confirm + url(r'^password/reset/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', + 'password_reset_confirm', + {'template_name': 'account/password_reset_confirm.html'}, + name='password_reset_confirm'), + # reset password complete + url(r'^password/reset/complete/$', 'password_reset_complete', + {'template_name': 'account/password_reset_complete.html'}, + name='password_reset_complete'), ) urlpatterns += patterns('', -- cgit v1.2.2