diff options
author | Weitian LI <liweitianux@gmail.com> | 2014-04-26 23:57:55 +0800 |
---|---|---|
committer | Weitian LI <liweitianux@gmail.com> | 2014-04-26 23:57:55 +0800 |
commit | e166ea9dd833f5d22f8a32d36fd4ed539c902410 (patch) | |
tree | b27f256bc07599b86f9c71656a255e2b5ba47ebb | |
parent | a2beffe243e20a2cf3d8e24b6f19064a0c8990f5 (diff) | |
download | django-skaschool-e166ea9dd833f5d22f8a32d36fd4ed539c902410.tar.bz2 |
* implemented 'password_reset' function based on django auth views
* added password_reset related templates and email templates
* updated account urls.py
-rw-r--r-- | account/templates/account/login.html | 3 | ||||
-rw-r--r-- | account/templates/account/password_reset_complete.html | 20 | ||||
-rw-r--r-- | account/templates/account/password_reset_confirm.html | 36 | ||||
-rw-r--r-- | account/templates/account/password_reset_done.html | 20 | ||||
-rw-r--r-- | account/templates/account/password_reset_email.html | 12 | ||||
-rw-r--r-- | account/templates/account/password_reset_form.html | 25 | ||||
-rw-r--r-- | account/templates/account/password_reset_subject.txt | 1 | ||||
-rw-r--r-- | account/urls.py | 50 |
8 files changed, 152 insertions, 15 deletions
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 %} </form> + + <br> + <p>忘记密码了? <a href="{% url 'password_reset' %}" class="btn btn-default">重置密码</a></p> </div> {% 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 %} + <div class="container"> + <h2>成功设置新密码</h2> + <br> + <p>您已成功设置了新的登录密码。 <a href="{% url 'login' %}" class="btn btn-primary">登录</a></p> + </div> +{% 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 %} + <div class="container"> + {% if validlink %} + <h2>设置新密码</h2> + <br> + <p>请在以下为您的账户设置新登录密码。</p> + <form role="form" class="form-horizontal" method="post"> + {% csrf_token %} + {% bootstrap_form form layout='horizontal' %} + {% buttons submit='提交' reset='重置' layout='horizontal' %}{% endbuttons %} + </form> + {% else %} + <h2>重置密码失败</h2> + <br> + <p>很抱歉,您使用的链接无效,可能该链接已被使用过,您可以尝试重新请求重置密码。</p> + <p>如果仍有问题,请与我们联系:<a href="mailto:skaschool2014@163.com"><code>skaschool2014@163.com</code></a></p> + {% endif %} + </div> +{% 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 %} + <div class="container"> + <h2>已发送重置邮件</h2> + <p>我们已经向您的邮件发送了重置密码邮件,请留意查收,并使用其中的链接重置密码。</p> + <p>如果您未能收到邮件,请确认是否正确输入您当时注册使用的邮箱。如果仍有问题,请与我们联系:<a href="mailto:skaschool2014@163.com"><code>skaschool2014@163.com</code></a></p> + </div> +{% 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 %} + <div class="container"> + <h2>重置密码</h2> + <br> + <p>请在下面输入您注册时使用的邮箱地址,然后我们将发送邮件以帮助您重新设置密码。</p> + <form role="form" class="form-horizontal" method="post"> + {% csrf_token %} + {% bootstrap_form form layout='horizontal' %} + {% buttons submit='提交' layout='horizontal' %}{% endbuttons %} + </form> + </div> +{% 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<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[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('', |