Correctly display errors.

fix #387
This commit is contained in:
Antoine Nguyen
2013-03-09 10:10:29 +01:00
parent ab9b574def
commit 2fb4e630f7
3 changed files with 19 additions and 14 deletions
+11 -11
View File
@@ -760,24 +760,24 @@ class Mailbox(DatesAware):
return True
@staticmethod
def resolve_uid(value):
def resolve_id(value, idname, errmsg):
if value.isdigit():
return value
try:
uid = pwd.getpwnam(value).pw_uid
rid = getattr(pwd.getpwnam(value), idname)
except KeyError:
raise AdminError(_("%s is not a valid uid/username" % value))
return uid
raise AdminError(errmsg)
return rid
@staticmethod
def resolve_uid(value):
err = _("%s is not a valid uid/username" % value)
return Mailbox.resolve_id(value, "pw_uid", err)
@staticmethod
def resolve_gid(value):
if value.isdigit():
return value
try:
gid = pwd.getpwnam(value).pw_gid
except KeyError:
raise AdminError(_("%s is not a valid gid/groupname" % value))
return gid
err = _("%s is not a valid gid/groupname" % value)
return Mailbox.resolve_id(value, "pw_gid", err)
def set_ownership(self):
"""Set uid and gid for this mailbox
@@ -1,7 +1,7 @@
{% load i18n %}
{% load i18n %}{% load url from future %}
{% url "modoboa.admin.views.saveparameters" as action %}
<h2>{% trans "Parameters" %} <small>{% trans "Configure Modoboa" %}</small></h2><hr />
<form id="settings_form" method="POST" action="{{ action }}" class="form-horizontal">
<form id="settings_form" method="POST" action="{% url 'modoboa.admin.views.saveparameters' %}" class="form-horizontal">
{% include "common/parameters.html" %}
</form>
<hr>
+6 -1
View File
@@ -33,10 +33,15 @@ TwocolsNav.prototype = {
},
update_content: function(data) {
$('#' + this.options.divid).html(data.content);
if (data.content) {
$('#' + this.options.divid).html(data.content);
}
if (data.onload_cb) {
eval(data.onload_cb + '()');
}
if (data.respmsg) {
$("body").notify("error", data.respmsg);
}
$('#' + this.options.divid + ' select').change($.proxy(this.select_change, this));
$(".help").popover().click(function(e) {e.preventDefault();});
$('#' + this.options.divid + ' select').change();