summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraylu <raylu@cmu.edu>2011-05-13 02:53:41 -0400
committerraylu <raylu@cmu.edu>2011-05-13 02:53:41 -0400
commit4d5a1f4ed62a1cb789832423ba1b13f13bc62c71 (patch)
tree7fa27bf401488d01a273ce57526a16218c73b404
parent3df8951964442e52f5445d9f51bc2d53764e3c4f (diff)
downloadpyc-4d5a1f4ed62a1cb789832423ba1b13f13bc62c71.tar.xz
Password changing
-rw-r--r--pyc/grader/views.py3
-rw-r--r--pyc/templates/index.html2
-rw-r--r--pyc/templates/login.html4
-rw-r--r--pyc/templates/password.html29
-rw-r--r--pyc/templates/password_changed.html9
-rw-r--r--pyc/urls.py2
6 files changed, 47 insertions, 2 deletions
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.
<p>
{% if authenticated %}
+ <a href="{% url django.contrib.auth.views.password_change %}">Change Password</a>
+ <br />
<a href="{% url django.contrib.auth.views.logout %}">Logout</a>
{% else %}
<a href="{% url django.contrib.auth.views.login %}">Login</a>
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 %}
<form method="post" action="{% url 'django.contrib.auth.views.login' %}">
-{% csrf_token %}
<table>
<tr>
<td style="text-align: right">{{ form.username.label_tag }}</td>
@@ -18,8 +17,9 @@
<td>{{ form.password }}</td>
</tr>
</table>
+{% csrf_token %}
-<input type="submit" value="login" />
+<input type="submit" value="Login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
{% 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 %}
+<p>An error occured.</p>
+{% endif %}
+
+<form method="post" action="{% url 'django.contrib.auth.views.password_change' %}">
+{% csrf_token %}
+<table>
+ <tr>
+ <td style="text-align: right">{{ form.old_password.label_tag }}</td>
+ <td>{{ form.old_password }}</td>
+ </tr>
+ <tr>
+ <td style="text-align: right">{{ form.new_password1.label_tag }}</td>
+ <td>{{ form.new_password1 }}</td>
+ </tr>
+ <tr>
+ <td style="text-align: right">{{ form.new_password2.label_tag }}</td>
+ <td>{{ form.new_password2 }}</td>
+ </tr>
+</table>
+
+<input type="submit" value="Change" />
+<input type="hidden" name="next" value="{{ next }}" />
+</form>
+{% 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.
+<p>
+<a href="/">Home</a>
+</p>
+{% 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')),