From 15da1c8b51b7ff201118c23cd75289124a7da7f0 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 4 Jun 2016 12:40:57 +0200 Subject: [PATCH] Add possibility to change password --- .../authentication/change_password.html | 17 +++++++++++++++++ authentication/urls.py | 5 ++++- authentication/views.py | 7 +++++++ templates/navbar.html | 9 +++++---- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 authentication/templates/authentication/change_password.html create mode 100644 authentication/views.py diff --git a/authentication/templates/authentication/change_password.html b/authentication/templates/authentication/change_password.html new file mode 100644 index 0000000..9e128e7 --- /dev/null +++ b/authentication/templates/authentication/change_password.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} +{% load crispy_forms_filters %} + +{% block content %} +

{% block title %}Change password{% endblock %}

+ +
+
+ {% if next %} + + {% endif %} + {% csrf_token %} + {{ form|crispy }} + +
+
+{% endblock %} \ No newline at end of file diff --git a/authentication/urls.py b/authentication/urls.py index 9a21225..457b9a7 100644 --- a/authentication/urls.py +++ b/authentication/urls.py @@ -1,5 +1,6 @@ from django.conf.urls import url -from django.contrib.auth.views import login, logout +from django.contrib.auth.views import login, logout, password_change +from authentication.views import password_change_done urlpatterns = [ url(r'^login/$', @@ -12,4 +13,6 @@ urlpatterns = [ {'next_page': 'home'}, name='auth_logout' ), + url(r'^password/change/$', password_change, {'template_name': 'authentication/change_password.html'}, name='password_change'), + url(r'^password/change/done/$', password_change_done, name='password_change_done'), ] diff --git a/authentication/views.py b/authentication/views.py new file mode 100644 index 0000000..811ef21 --- /dev/null +++ b/authentication/views.py @@ -0,0 +1,7 @@ +from django.shortcuts import render, redirect, get_object_or_404 +from django.contrib import messages + + +def password_change_done(request): + messages.success(request, "Password changed successfully") + return render(request, 'refunds/home.html') diff --git a/templates/navbar.html b/templates/navbar.html index dd461c9..256b8e4 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -24,20 +24,21 @@