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
+2 -1
View File
@@ -14,7 +14,8 @@
<td>{{ mbox.get_quota }}M</td>
<td>{{ mbox.quota }}M</td>
<td name="quota">
<div id="quotabar" class="progress {% progress_color mbox.get_quota_in_percent %}">
<div id="quotabar" rel="tooltip" title="{{ mbox.get_quota_in_percent }}%"
class="progress {% progress_color mbox.get_quota_in_percent %}">
<div class="bar" style="width: {{ mbox.get_quota_in_percent }}%"></div>
</div>
</td>
+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: