diff --git a/admin/forms.py b/admin/forms.py index 8f868dccd..28faea938 100644 --- a/admin/forms.py +++ b/admin/forms.py @@ -285,10 +285,10 @@ class AccountFormGeneralPwd(AccountFormGeneral): class AccountFormMail(forms.Form, DynamicForm): # FIXME - # * ajout du quota # * Renommage de boite ? email = forms.EmailField(label=_("E-mail"), required=False) + quota = forms.IntegerField(label=_("Quota"), required=False) aliases = forms.EmailField( label=ugettext_noop("Alias(es)"), required=False, @@ -309,6 +309,7 @@ class AccountFormMail(forms.Form, DynamicForm): name = "aliases_%d" % (pos + 1) self._create_field(forms.EmailField, name, alias.full_address) self.fields["email"].initial = self.mb.full_address + self.fields["quota"].initial = self.mb.quota if len(args) and isinstance(args[0], QueryDict): self._load_from_qdict(args[0], "aliases", forms.EmailField) @@ -331,7 +332,8 @@ class AccountFormMail(forms.Form, DynamicForm): except Mailbox.DoesNotExist: events.raiseEvent("CanCreate", user, "mailboxes") self.mb = Mailbox() - self.mb.save_from_user(locpart, domain, account) + self.mb.save_from_user(locpart, domain, account, + self.cleaned_data["quota"]) grant_access_to_object(user, self.mb, is_owner=True) events.raiseEvent("CreateMailbox", user, self.mb) else: @@ -339,9 +341,9 @@ class AccountFormMail(forms.Form, DynamicForm): if self.mb.rename_dir(domname, locpart): self.mb.domain = domain self.mb.address = locpart - self.mb.save() else: raise AdminError(_("Failed to rename mailbox, check permissions")) + self.mb.save(quota=self.cleaned_data["quota"]) account.email = self.cleaned_data["email"] account.save() diff --git a/admin/models.py b/admin/models.py index bb476e456..f08f4be76 100644 --- a/admin/models.py +++ b/admin/models.py @@ -584,7 +584,7 @@ class Mailbox(DatesAware): pass super(Mailbox, self).save(*args, **kwargs) - def save_from_user(self, localpart, domain, user): + def save_from_user(self, localpart, domain, user, quota=None): """Simple save method called for automatic creations :param localpart: the mailbox @@ -608,7 +608,7 @@ class Mailbox(DatesAware): self.gid = v_gid else: self.gid = pwd.getpwnam(parameters.get_admin("VIRTUAL_GID")).pw_gid - self.quota = self.domain.quota + self.quota = self.domain.quota if quota is None else quota super(Mailbox, self).save() def create_from_csv(self, user, line): diff --git a/admin/views.py b/admin/views.py index f40d27c40..5977f7fd6 100644 --- a/admin/views.py +++ b/admin/views.py @@ -93,7 +93,7 @@ def newdomain(request): @permission_required("admin.change_domain") def editdomain(request, dom_id, tplname="admin/domainform.html"): domain = Domain.objects.get(pk=dom_id) - if not request.user.is_owner(domain): + if not request.user.can_access(domain): raise PermDeniedException(_("You can't edit this domain")) commonctx = {"title" : _("Domain editing"), @@ -210,7 +210,7 @@ def newdlist(request, tplname="common/generic_modal_form.html"): @permission_required("admin.change_alias") def editdlist(request, dlist_id, tplname="admin/dlistform.html"): dlist = Alias.objects.get(pk=dlist_id) - if not request.user.is_owner(dlist.domain): + if not request.user.can_access(dlist.domain): raise PermDeniedException(_("You do not have access to this domain")) commonctx = {"title" : dlist.full_address, "action_label" : _("Update"), @@ -233,7 +233,7 @@ def deldlist(request): selection = request.GET["selection"].split(",") for dlist_id in selection: dlist = Alias.objects.get(pk=dlist_id) - if not request.user.is_owner(dlist.domain): + if not request.user.can_access(dlist.domain): raise PermDeniedException(_("You do not have access to this domain")) events.raiseEvent("MailboxAliasDeleted", dlist) ungrant_access_to_object(dlist) diff --git a/static/js/admin.js b/static/js/admin.js index 740a099e0..5ab4c3516 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -28,7 +28,9 @@ function newaccount_cb() { function editaccount_cb() { accountform_init(); $('#submit').click(function(e) { - simple_ajax_form_post(e, editaccount_cb); + simple_ajax_form_post(e, { + error_cb: editaccount_cb + }); }); } @@ -39,7 +41,9 @@ function dlistform_cb() { }); $("#id_recipients").dynamic_input(); $(".submit").one('click', function(e) { - simple_ajax_form_post(e, dlistform_cb); + simple_ajax_form_post(e, { + error_cb: dlistform_cb + }); }); } diff --git a/static/js/confirmation.js b/static/js/confirmation.js index 3cb183881..0d65e3bf3 100644 --- a/static/js/confirmation.js +++ b/static/js/confirmation.js @@ -10,7 +10,7 @@ show: function(e) { e.preventDefault(); - + this.box = this.buildbox(); this.box.modal(); this.box.on('hidden', $.proxy(this.hidden_callback, this)); @@ -85,6 +85,8 @@ } if (data.status == "ok") { window.location.reload(); + } else { + $("body").notify("error", data.respmsg); } } }); diff --git a/static/js/history.js b/static/js/history.js index 571994dee..bcf2e3aea 100644 --- a/static/js/history.js +++ b/static/js/history.js @@ -151,10 +151,10 @@ History.prototype = { }, getparam: function(name) { - if (!this.params.has(name)) { + if (this.params[name] === undefined) { return ""; } - return this.params.get(name); + return this.params[name]; }, baseurl: function(value, noreset) { diff --git a/static/js/jquery.htmltable.js b/static/js/jquery.htmltable.js index 89bcfe7c3..d428ab03b 100644 --- a/static/js/jquery.htmltable.js +++ b/static/js/jquery.htmltable.js @@ -25,8 +25,11 @@ }, listen: function() { - $(document).on("click", "tbody>tr", - $.proxy(this.toggle_select, this)); + + $(document) + .off("click", "tbody>tr") + .on("click", "tbody>tr", + $.proxy(this.toggle_select, this)); $(document).on("keydown", "body", $.proxy(this.keydown, this)); $(document).on("keyup", "body", $.proxy(this.keyup, this)); }, @@ -66,6 +69,10 @@ this._toggle_select($tr); }, + is_selected: function($row) { + return $row.hasClass(this.options.tr_selected_class); + }, + current_selection: function() { return $("tr[class*=" + this.options.tr_selected_class + "]"); }, diff --git a/templates/admin/listing.html b/templates/admin/listing.html index e9c6c6f17..e1b6135cc 100644 --- a/templates/admin/listing.html +++ b/templates/admin/listing.html @@ -7,7 +7,5 @@ {% block apparea %} {{ table|safe }} {% endblock %} -{% block footer %} -
{% get_footer_content user selection %}
-{% pagination_bar page %} -{% endblock %} +{% block footerleft %}
{% get_footer_content user selection %}
{% endblock %} +{% block footerright %}{% pagination_bar page %}{% endblock %} diff --git a/templates/admin/mailform.html b/templates/admin/mailform.html index 74f879343..7ab8f295b 100644 --- a/templates/admin/mailform.html +++ b/templates/admin/mailform.html @@ -1,3 +1,4 @@ {% load libextras %} {% render_field form.email %} +{% render_field form.quota %} {% render_fields_group form "aliases" %} diff --git a/templates/common/error_simple.html b/templates/common/error_simple.html index ddebe672e..435b88dc2 100644 --- a/templates/common/error_simple.html +++ b/templates/common/error_simple.html @@ -1,4 +1,4 @@ -{% extends "layout_simple.html" %} +{% extends "nlayout.html" %} {% block content %} -

{{ error }}

+
{{ error }}
{% endblock %}