From 4d5a1f4ed62a1cb789832423ba1b13f13bc62c71 Mon Sep 17 00:00:00 2001 From: raylu Date: Fri, 13 May 2011 02:53:41 -0400 Subject: Password changing --- pyc/grader/views.py | 3 +++ pyc/templates/index.html | 2 ++ pyc/templates/login.html | 4 ++-- pyc/templates/password.html | 29 +++++++++++++++++++++++++++++ pyc/templates/password_changed.html | 9 +++++++++ pyc/urls.py | 2 ++ 6 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 pyc/templates/password.html create mode 100644 pyc/templates/password_changed.html diff --git a/pyc/grader/views.py b/pyc/grader/views.py index 7e36eef..479dc63 100644 --- a/pyc/grader/views.py +++ b/pyc/grader/views.py @@ -9,6 +9,9 @@ def index(request): 'authenticated' : request.user.is_authenticated(), }) +def password_changed(request): + return render_to_response('password_changed.html') + def lab(request, lab_id): lab = Lab.objects.get(pk=lab_id) submissions = lab.submission_set.filter(user__is_staff=False).order_by('-grade', '-time') diff --git a/pyc/templates/index.html b/pyc/templates/index.html index f2372ea..439beb9 100644 --- a/pyc/templates/index.html +++ b/pyc/templates/index.html @@ -19,6 +19,8 @@ If you are interested, please contact raylu.

{% if authenticated %} + Change Password +
Logout {% else %} Login diff --git a/pyc/templates/login.html b/pyc/templates/login.html index b80abee..f0294d8 100644 --- a/pyc/templates/login.html +++ b/pyc/templates/login.html @@ -7,7 +7,6 @@ {% endif %}

-{% csrf_token %} @@ -18,8 +17,9 @@
{{ form.username.label_tag }}{{ form.password }}
+{% csrf_token %} - +
{% endblock %} diff --git a/pyc/templates/password.html b/pyc/templates/password.html new file mode 100644 index 0000000..a155dbe --- /dev/null +++ b/pyc/templates/password.html @@ -0,0 +1,29 @@ +{% extends 'base.html' %} +{% load url from future %} + +{% block body %} +{% if form.errors %} +

An error occured.

+{% endif %} + +
+{% csrf_token %} + + + + + + + + + + + + + +
{{ form.old_password.label_tag }}{{ form.old_password }}
{{ form.new_password1.label_tag }}{{ form.new_password1 }}
{{ form.new_password2.label_tag }}{{ form.new_password2 }}
+ + + +
+{% endblock %} diff --git a/pyc/templates/password_changed.html b/pyc/templates/password_changed.html new file mode 100644 index 0000000..2cd2532 --- /dev/null +++ b/pyc/templates/password_changed.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} +{% load url from future %} + +{% block body %} +Password successfully changed. +

+Home +

+{% endblock %} diff --git a/pyc/urls.py b/pyc/urls.py index 8132990..eaa5026 100644 --- a/pyc/urls.py +++ b/pyc/urls.py @@ -10,6 +10,8 @@ urlpatterns = patterns('', url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}), url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}), + url(r'^password/$', 'django.contrib.auth.views.password_change', {'template_name': 'password.html', 'post_change_redirect': '/password_changed'}), + url(r'^password_changed/$', 'grader.views.password_changed'), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), -- cgit v1.2.3