From 7a1f582dd1ae7ddfe9765c74b6dc828d4b6ad904 Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Sun, 20 Apr 2014 19:04:25 +0800 Subject: added 'password_change' and 'password_change_done' views and templates --- account/templates/account/password_change.html | 24 ++++++++++++++++++++++ .../templates/account/password_change_done.html | 21 +++++++++++++++++++ account/urls.py | 19 +++++++++++++---- 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 account/templates/account/password_change.html create mode 100644 account/templates/account/password_change_done.html diff --git a/account/templates/account/password_change.html b/account/templates/account/password_change.html new file mode 100644 index 0000000..372bb0c --- /dev/null +++ b/account/templates/account/password_change.html @@ -0,0 +1,24 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% load url from future %} +{% load bootstrap3 %} + +{# login template #} + +{% block title %} +修改密码 | 2014 SKA Summer School +{% endblock %} + +{% block content %} +
+

修改密码

+
+
+ {% csrf_token %} + {% bootstrap_form form layout='horizontal' %} + {% buttons submit='提交' reset='重置' 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_change_done.html b/account/templates/account/password_change_done.html new file mode 100644 index 0000000..e003033 --- /dev/null +++ b/account/templates/account/password_change_done.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% load url from future %} +{% load bootstrap3 %} + +{# login 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/urls.py b/account/urls.py index c73d59c..671ac9a 100644 --- a/account/urls.py +++ b/account/urls.py @@ -7,6 +7,7 @@ customize 'registration.backends.default.urls' to use custom form from django.conf.urls import patterns, include, url from django.views.generic.base import TemplateView +from django.contrib.auth.decorators import login_required from registration.backends.default.views import ActivationView from registration.backends.default.views import RegistrationView @@ -40,6 +41,10 @@ urlpatterns = patterns('', url(r'^activate/(?P\w+)/$', ActivationView.as_view(), name='registration_activate'), + ## profile + url(r'^profile/$', + login_required(TemplateView.as_view(template_name='account/profile.html')), + name='profile'), ## django auth views # login url(r'^login/$', 'django.contrib.auth.views.login', @@ -49,10 +54,16 @@ urlpatterns = patterns('', url(r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'account/logout.html'}, name='logout'), - # profile - url(r'^profile/$', - TemplateView.as_view(template_name='account/profile.html'), - name='profile'), + # 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', + {'template_name': 'account/password_change.html'}, + name='password_change'), + # change password done + url(r'^password/change/done$', 'django.contrib.auth.views.password_change_done', + {'template_name': 'account/password_change_done.html'}, + name='password_change_done'), ) -- cgit v1.2.2