#285 append tabs to password-change-view

This commit is contained in:
Oskar Hahn 2012-07-11 09:46:15 +02:00
parent 68215e78d6
commit 07a0d42577
2 changed files with 24 additions and 3 deletions

View File

@ -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):

View File

@ -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',
),
)