aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-04-20 17:01:59 +0800
committerWeitian LI <liweitianux@gmail.com>2014-04-20 17:01:59 +0800
commit5bd3311371eddda6952ea85b41c6f59d36d7dd3b (patch)
treeb4fddb6f39564003b3948cbdad98281c69e392c7
parent733a218f0c807dd6c6c60addca1cb3c512207993 (diff)
downloaddjango-skaschool-5bd3311371eddda6952ea85b41c6f59d36d7dd3b.tar.bz2
* updated django_skaschool/settings.py
o LOGIN_URL, LOGIN_REDIRECT_URL, LOGOUT_URL * added login/logout views to account urls.py * added account templates for login, logout, profile
-rw-r--r--account/templates/account/login.html24
-rw-r--r--account/templates/account/logout.html19
-rw-r--r--account/templates/account/profile.html21
-rw-r--r--account/urls.py17
-rw-r--r--django_skaschool/settings.py12
5 files changed, 90 insertions, 3 deletions
diff --git a/account/templates/account/login.html b/account/templates/account/login.html
new file mode 100644
index 0000000..b41844e
--- /dev/null
+++ b/account/templates/account/login.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 %}
+ <div class="container">
+ <h2>登录</h2>
+ <br />
+ <form role="form" class="form-horizontal" method="post">
+ {% csrf_token %}
+ {% bootstrap_form form layout='horizontal' %}
+ {% buttons submit='提交' reset='取消' 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/logout.html b/account/templates/account/logout.html
new file mode 100644
index 0000000..7e3ac4a
--- /dev/null
+++ b/account/templates/account/logout.html
@@ -0,0 +1,19 @@
+{% extends 'base.html' %}
+{% load staticfiles %}
+{% load url from future %}
+{% load bootstrap3 %}
+
+{# login template #}
+
+{% block title %}
+已退出 | 2014 SKA Summer School
+{% endblock %}
+
+{% block content %}
+ <div class="container">
+ <h2>已退出</h2>
+ <p class="lead">您已成功退出。</p>
+ </div>
+{% endblock %}
+
+{# vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=htmldjango.html: #}
diff --git a/account/templates/account/profile.html b/account/templates/account/profile.html
new file mode 100644
index 0000000..aac992f
--- /dev/null
+++ b/account/templates/account/profile.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 %}
+ <div class="container">
+ <h2>个人主页</h2>
+ <p class="lead">TODO ...</p>
+
+ <br />
+ </div>
+{% 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 3ae8d12..c73d59c 100644
--- a/account/urls.py
+++ b/account/urls.py
@@ -32,7 +32,7 @@ urlpatterns = patterns('',
url(r'^activate/complete/$',
TemplateView.as_view(template_name='registration/activation_complete.html'),
name='registration_activation_complete'),
- # 3. registration_activate
+ # 3. registration_activate (place this section *AFTER* step 4)
# Activation keys get matched by \w+ instead of the more specific
# [a-fA-F0-9]{40} because a bad activation key should still get to the view;
# that way it can return a sensible "invalid key" message instead of a
@@ -40,8 +40,19 @@ urlpatterns = patterns('',
url(r'^activate/(?P<activation_key>\w+)/$',
ActivationView.as_view(),
name='registration_activate'),
- ## django auth
- #(r'', include('registration.auth_urls')),
+ ## 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'),
+ # profile
+ url(r'^profile/$',
+ TemplateView.as_view(template_name='account/profile.html'),
+ name='profile'),
)
diff --git a/django_skaschool/settings.py b/django_skaschool/settings.py
index 79d0299..b61a474 100644
--- a/django_skaschool/settings.py
+++ b/django_skaschool/settings.py
@@ -96,6 +96,18 @@ USE_TZ = True
# contrib.sites
SITE_ID = 1
+# The URL where requests are redirected after login when the
+# 'contrib.auth.login' view gets no 'next' parameter.
+LOGIN_REDIRECT_URL = '/accounts/profile/'
+
+# The URL where requests are redirected for login,
+# especially when using the 'login_required()' decorator.
+LOGIN_URL = '/accounts/login/'
+
+# The URL redirected to after logout
+LOGOUT_URL = '/accounts/logout/'
+
+
## template directories
TEMPLATE_DIRS = (
# Don't forget to use absolute paths, not relative paths.