Fixing sql query.

see #392
This commit is contained in:
Antoine Nguyen
2013-04-18 17:19:23 +02:00
parent 50a8bf1b9d
commit 39449a9712
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -354,8 +354,10 @@ def list_quotas(request, tplname="admin/quotas.html"):
if sort_order in ["address", "quota", "quota_value__bytes"]:
mboxes = mboxes.order_by("%s%s" % (sort_dir, sort_order))
elif sort_order == "quota_usage":
mboxes.select_related().extra(
select={'quota_usage': 'quota_value.bytes / (quota * 1048576) * 100'},
mboxes.extra(
select={'quota_usage': 'admin_quota.bytes / (admin_mailbox.quota * 1048576) * 100'},
where=["admin_quota.mbox_id=admin_mailbox.id"],
tables=["admin_quota"],
order_by=["%s%s" % (sort_dir, sort_order)]
)
else: