diff --git a/core/templates/core/password_change.html b/core/templates/core/password_change.html new file mode 100644 index 00000000..0c41975d --- /dev/null +++ b/core/templates/core/password_change.html @@ -0,0 +1,14 @@ +{% extends "core/base.html" %} + +{% block content %} + +{% if form.errors %} +

Your passwords didn't match. Please try again.

+{% endif %} + +
+{% csrf_token %} +{{ form.as_p }} + +
+{% endblock %} diff --git a/core/templates/core/password_change_done.html b/core/templates/core/password_change_done.html new file mode 100644 index 00000000..6f3636a8 --- /dev/null +++ b/core/templates/core/password_change_done.html @@ -0,0 +1,12 @@ +{% extends "core/base.html" %} + +{% block content %} + +You successfully changed your password! + +{% if form.errors %} +

Your passwords didn't match. Please try again.

+{% endif %} + +{% endblock %} + diff --git a/core/urls.py b/core/urls.py index cf760862..94b4507b 100644 --- a/core/urls.py +++ b/core/urls.py @@ -4,10 +4,19 @@ from core.views import * urlpatterns = [ url('^', include('django.contrib.auth.urls')), + url(r'^$', index, name='index'), + url(r'^login$', login, name='login'), url(r'^logout$', logout, name='logout'), + url(r'^password_change$', password_change, name='password_change'), + url(r'^password_change/done$', password_change_done, name='password_change_done'), + url(r'^password_reset$', password_reset, name='password_reset'), + url(r'^password_reset/done$', password_reset_done, name='password_reset_done'), + url(r'^reset/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', password_reset_confirm, name='password_reset_confirm'), + url(r'^reset/done/$', password_reset_complete, name='password_reset_complete'), url(r'^register$', register, name='register'), + url(r'^user/$', user, name='user_list'), url(r'^user/(?P[0-9]+)/$', user, name='user_profile'), url(r'^user/(?P[0-9]+)/edit$', user_edit, name='user_edit'), diff --git a/core/views/user.py b/core/views/user.py index f39407fa..7d6512d7 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -1,7 +1,6 @@ # This file contains all the views that concern the user model from django.shortcuts import render, redirect, get_object_or_404 -from django.contrib.auth import logout as auth_logout -from django.contrib.auth import views +from django.contrib.auth import logout as auth_logout, views from django.contrib.auth.forms import PasswordChangeForm from django.core.urlresolvers import reverse import logging @@ -9,6 +8,44 @@ import logging from core.views.forms import RegisteringForm, LoginForm, UserEditForm from core.models import User +def login(request): + """ + The login view + + Needs to be improve with correct handling of form exceptions + """ + return views.login(request, template_name="core/login.html") + +def logout(request): + """ + The logout view + """ + return views.logout_then_login(request) + +def password_change(request): + """ + Allows a user to change its password + """ + return views.password_change(request, template_name="core/password_change.html") + +def password_change_done(request): + """ + Allows a user to change its password + """ + return views.password_change_done(request, template_name="core/password_change_done.html") + +def password_reset_confirm(request): + pass + +def password_reset_complete(request): + pass + +def password_reset_done(request): + pass + +def password_reset(request): + pass + def register(request): context = {'title': 'Register a user'} if request.method == 'POST': @@ -27,20 +64,6 @@ def register(request): context['form'] = form.as_p() return render(request, "core/register.html", context) -def login(request): - """ - The login view - - Needs to be improve with correct handling of form exceptions - """ - return views.login(request, template_name="core/login.html") - -def logout(request): - """ - The logout view - """ - return views.logout_then_login(request) - def user(request, user_id=None): """ Display a user's profile diff --git a/sith/settings.py b/sith/settings.py index e9dd98ab..2757b3c6 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -103,4 +103,5 @@ USE_TZ = True STATIC_URL = '/static/' AUTH_USER_MODEL = 'core.User' LOGIN_URL = '/login' +LOGOUT_URL = '/logout' LOGIN_REDIRECT_URL = '/'