mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-02 12:13:54 +01:00
@@ -37,7 +37,8 @@ def user_menu(user):
|
||||
"url" : reverse("modoboa.userprefs.views.changepassword"),
|
||||
"img" : "icon-edit",
|
||||
"label" : _("Change password"),
|
||||
"modal" : True},
|
||||
"modal" : True,
|
||||
"modalcb" : "chpasswordform_cb"},
|
||||
{"name" : "preferences",
|
||||
"img" : "icon-list",
|
||||
"label" : _("Preferences"),
|
||||
|
||||
+14
-8
@@ -1,3 +1,4 @@
|
||||
# coding: utf-8
|
||||
import copy
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
@@ -18,12 +19,20 @@ def index(request):
|
||||
return HttpResponseRedirect(reverse(preferences))
|
||||
|
||||
@login_required
|
||||
def changepassword(request, tplname="userprefs/chpassword.html"):
|
||||
def changepassword(request, tplname="common/generic_modal_form.html"):
|
||||
res = events.raiseQueryEvent("PasswordChange", request.user)
|
||||
if True in res:
|
||||
ctx = dict(error=_("Password change is disabled for this user"))
|
||||
return _render_error(request, errortpl="error_simple", user_context=ctx)
|
||||
|
||||
ctx = dict(
|
||||
title=_("Change password"),
|
||||
formid="chpasswordform",
|
||||
action=reverse(changepassword),
|
||||
action_label=_("Update"),
|
||||
action_classes="submit",
|
||||
)
|
||||
|
||||
error = None
|
||||
if request.method == "POST":
|
||||
form = ChangePasswordForm(request.user, request.POST)
|
||||
@@ -38,14 +47,11 @@ def changepassword(request, tplname="userprefs/chpassword.html"):
|
||||
request.user.save()
|
||||
if error is None:
|
||||
return ajax_response(request, respmsg=_("Password changed"))
|
||||
ctx.update(form=form, error=error)
|
||||
return ajax_response(request, status="ko", template=tplname, **ctx)
|
||||
|
||||
return ajax_response(request, status="ko", template=tplname,
|
||||
form=form, error=error)
|
||||
|
||||
form = ChangePasswordForm(request.user)
|
||||
return _render(request, 'userprefs/chpassword.html', {
|
||||
"form" : form
|
||||
})
|
||||
ctx.update(form=ChangePasswordForm(request.user))
|
||||
return _render(request, tplname, ctx)
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.belongs_to_group('SimpleUsers'))
|
||||
|
||||
Reference in New Issue
Block a user