From 07a0d4257797d88727d81c4ad2e20c00df7e8049 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 11 Jul 2012 09:46:15 +0200 Subject: [PATCH] #285 append tabs to password-change-view --- openslides/participant/views.py | 23 +++++++++++++++++++++++ openslides/urls.py | 4 +--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/openslides/participant/views.py b/openslides/participant/views.py index 5d3c67bcd..9676e2e2f 100644 --- a/openslides/participant/views.py +++ b/openslides/participant/views.py @@ -30,6 +30,7 @@ from django.db import transaction from django.contrib import messages from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User, Group +from django.contrib.auth.forms import PasswordChangeForm from django.core.urlresolvers import reverse from django.shortcuts import redirect from django.utils.translation import ugettext as _, ungettext @@ -359,6 +360,28 @@ def user_settings(request): } +@login_required +@template('participant/password_change.html') +def user_settings_password(request): + """ + Edit own password. + """ + if request.method == 'POST': + form = PasswordChangeForm(request.user, request.POST) + if form.is_valid(): + form.save() + messages.success(request, _('Password successfully changed.')) + return redirect(reverse('user_settings')) + else: + messages.error(request, _('Please check the form for errors.')) + else: + form = PasswordChangeForm(user=request.user) + + return { + 'form': form, + } + + @permission_required('participant.can_manage_participant') @template('participant/import.html') def user_import(request): diff --git a/openslides/urls.py b/openslides/urls.py index 85a15fd49..e9b93fd53 100644 --- a/openslides/urls.py +++ b/openslides/urls.py @@ -69,9 +69,7 @@ urlpatterns += patterns('', ), url(r'^usersettings/changepassword/$', - 'django.contrib.auth.views.password_change', - {'template_name': 'participant/password_change.html', - 'post_change_redirect': '/usersettings/'}, + 'openslides.participant.views.user_settings_password', name='password_change', ), )