diff --git a/modoboa/extensions/admin/static/admin/js/admin.js b/modoboa/extensions/admin/static/admin/js/admin.js index cba78830c..bef4d261a 100644 --- a/modoboa/extensions/admin/static/admin/js/admin.js +++ b/modoboa/extensions/admin/static/admin/js/admin.js @@ -31,8 +31,16 @@ Admin.prototype = { * @param {Object} data - response of the ajax call (JSON) */ list_cb: function(data) { - $("#objects_table tbody").html(data.rows); + if (data.rows) { + $("#objects_table tbody").html(data.rows); + } else { + $("#objects_table tbody").html(""); + } this.update_listing(data); + if (data.length === 0) { + this.get_load_page_args(); + this.end_of_list_reached(); + } }, /** diff --git a/modoboa/extensions/admin/views/identity.py b/modoboa/extensions/admin/views/identity.py index 71298e076..0c0a29b20 100644 --- a/modoboa/extensions/admin/views/identity.py +++ b/modoboa/extensions/admin/views/identity.py @@ -94,12 +94,14 @@ def list_quotas(request): else: raise BadRequest(_("Invalid request")) page = get_listing_page(mboxes, request.GET.get("page", 1)) - context = {} + context = { + "headers": _render_to_string( + request, "admin/quota_headers.html", {} + ) + } if page is None: context["length"] = 0 else: - context["headers"] = _render_to_string( - request, "admin/quota_headers.html", {}) context["rows"] = _render_to_string( request, "admin/quotas.html", { "mboxes": page @@ -146,14 +148,7 @@ def accounts_list(request): @permission_required("core.add_user") @reversion.create_revision() def newaccount(request): - """Create a new account. - - .. note:: An issue still remains int this code: if all validation - steps are successful but an error occurs after we call 'save', - the account will be created. It happens transaction management - doesn't work very well with nested functions. Need to wait for - django 1.6 and atomicity. - """ + """Create a new account.""" from modoboa.extensions.admin.forms import AccountWizard return AccountWizard(request).process() diff --git a/modoboa/lib/listing.py b/modoboa/lib/listing.py index 61a4f18f6..858b85b31 100644 --- a/modoboa/lib/listing.py +++ b/modoboa/lib/listing.py @@ -33,7 +33,8 @@ def get_listing_page(objects, pagenum): :return: a ``Page`` object """ paginator = Paginator( - objects, int(parameters.get_admin("ITEMS_PER_PAGE", app="core")) + objects, int(parameters.get_admin("ITEMS_PER_PAGE", app="core")), + allow_empty_first_page=False ) try: page = paginator.page(int(pagenum))