Displaying errors correctly

This commit is contained in:
Antoine Nguyen
2013-04-17 14:16:46 +02:00
parent 04fb7b1fee
commit de6d2794fa
2 changed files with 17 additions and 17 deletions
@@ -33,14 +33,14 @@ def autoreply(request, tplname="postfix_autoreply/autoreply.html"):
arm.mbox = mb
arm.save()
return ajax_simple_response(dict(
status="ok", respmsg=_("Auto reply message updated successfully.")
))
status="ok", respmsg=_("Auto reply message updated successfully.")
))
return ajax_simple_response({
"status" : "ko",
"content" : render_to_string(tplname, {"form" : form}),
"onload_cb" : "autoreply_cb"
})
"status": "ko",
"errors": form.errors,
"onload_cb": "autoreply_cb"
})
form = ARmessageForm(instance=arm)
if arm is not None:
+11 -11
View File
@@ -51,7 +51,7 @@ def forward(request, tplname='userprefs/forward.html'):
return ajax_simple_response(dict(
status="ko",
content=render_to_string(tplname, {"form" : form}),
errors=form.errors,
respmsg=error
))
@@ -84,20 +84,20 @@ def profile(request, tplname='userprefs/profile.html'):
if update_password:
request.session["password"] = encrypt(form.cleaned_data["confirmation"])
return ajax_simple_response(dict(
status="ok", respmsg=_("Profile updated")
))
status="ok", respmsg=_("Profile updated")
))
return ajax_simple_response({
"status" : "ko",
"content" : render_to_string(tplname, {"form" : form})
})
"status": "ko",
"errors": form.errors
})
form = ProfileForm(update_password, instance=request.user)
return ajax_simple_response({
"status" : "ok",
"content" : render_to_string(tplname, {
"form" : form
})
})
"status": "ok",
"content": render_to_string(tplname, {
"form": form
})
})
@login_required
def preferences(request):