Fixing few issues with infinite scroll.

This commit is contained in:
Antoine Nguyen
2014-12-31 11:24:27 +01:00
parent 1545f069cc
commit 213c5e5e46
3 changed files with 17 additions and 13 deletions
@@ -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();
}
},
/**
+6 -11
View File
@@ -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()
+2 -1
View File
@@ -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))