Display domain quota usage.

see #1030
This commit is contained in:
Antoine Nguyen
2017-02-15 15:41:57 +01:00
parent cdd2fcc2bc
commit b9342f7801
3 changed files with 70 additions and 31 deletions
+7
View File
@@ -167,6 +167,13 @@ class Domain(AdminObject):
return self.mailbox_set.aggregate(
total=models.Sum("quota"))["total"]
@cached_property
def quota_usage_in_percent(self):
"""Return quota usage in percent."""
if not self.quota_usage:
return 0
return int(self.quota_usage / float(self.quota) * 100)
def add_admin(self, account):
"""Add a new administrator to this domain.