From f2bfca665c69b1313a53e6041585224290ae732e Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Thu, 29 Jan 2015 16:14:06 +0100 Subject: [PATCH] Manually join with the admin_quota table. fix #679 --- modoboa/extensions/admin/views/identity.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modoboa/extensions/admin/views/identity.py b/modoboa/extensions/admin/views/identity.py index 0c0a29b20..28209ec36 100644 --- a/modoboa/extensions/admin/views/identity.py +++ b/modoboa/extensions/admin/views/identity.py @@ -74,8 +74,16 @@ def list_quotas(request): request.user, request.GET.get("searchquery", None) ) mboxes = mboxes.exclude(quota=0) - if sort_order in ["address", "quota", "quota_value__bytes"]: + if sort_order in ["address", "quota"]: mboxes = mboxes.order_by("%s%s" % (sort_dir, sort_order)) + elif sort_order == "quota_value__bytes": + where = "admin_mailbox.address||'@'||admin_domain.name" + mboxes = mboxes.extra( + select={"quota_value__bytes": "admin_quota.bytes"}, + where=["admin_quota.username=%s" % where], + tables=["admin_quota", "admin_domain"], + order_by=["%s%s" % (sort_dir, sort_order)] + ) elif sort_order == "quota_usage": where = "admin_mailbox.address||'@'||admin_domain.name" db_type = db_type()