mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-24 06:48:35 +02:00
@@ -244,11 +244,19 @@ class DomainTestCase(ModoTestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertIn("Summary", response.content.decode())
|
self.assertIn("Summary", response.content.decode())
|
||||||
self.assertIn("Administrators", response.content.decode())
|
self.assertIn("Administrators", response.content.decode())
|
||||||
|
self.assertIn("Usage", response.content.decode())
|
||||||
self.assertNotIn("Resources usage", response.content.decode())
|
self.assertNotIn("Resources usage", response.content.decode())
|
||||||
self.set_global_parameter("enable_domain_limits", True, app="limits")
|
self.set_global_parameter("enable_domain_limits", True, app="limits")
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertIn("Resources usage", response.content.decode())
|
self.assertIn("Resources usage", response.content.decode())
|
||||||
|
|
||||||
|
# Try a domain with no quota
|
||||||
|
domain = Domain.objects.filter(quota=0).first()
|
||||||
|
url = reverse("admin:domain_detail", args=[domain.pk])
|
||||||
|
response = self.client.get(url)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertNotIn("Usage", response.content.decode())
|
||||||
|
|
||||||
def test_statitics_widget(self):
|
def test_statitics_widget(self):
|
||||||
"""Test statistics display in dashboard."""
|
"""Test statistics display in dashboard."""
|
||||||
url = reverse("core:dashboard")
|
url = reverse("core:dashboard")
|
||||||
|
|||||||
@@ -176,20 +176,23 @@ class DomainDetailView(
|
|||||||
result = signals.extra_domain_dashboard_widgets.send(
|
result = signals.extra_domain_dashboard_widgets.send(
|
||||||
self.__class__, user=self.request.user, domain=self.object)
|
self.__class__, user=self.request.user, domain=self.object)
|
||||||
parameters = self.request.localconfig.parameters
|
parameters = self.request.localconfig.parameters
|
||||||
used_quota = int(
|
|
||||||
Quota.objects.get_domain_usage(self.object) / 1048576)
|
|
||||||
used_quota_in_percent = int(
|
|
||||||
used_quota / float(self.object.quota) * 100)
|
|
||||||
allocated_quota = (
|
|
||||||
self.object.allocated_quota_in_percent - used_quota_in_percent)
|
|
||||||
context.update({
|
context.update({
|
||||||
"templates": {"left": [], "right": []},
|
"templates": {"left": [], "right": []},
|
||||||
"enable_mx_checks": parameters.get_value("enable_mx_checks"),
|
"enable_mx_checks": parameters.get_value("enable_mx_checks"),
|
||||||
"enable_dnsbl_checks": parameters.get_value("enable_dnsbl_checks"),
|
"enable_dnsbl_checks": parameters.get_value("enable_dnsbl_checks"),
|
||||||
"used_quota": used_quota,
|
|
||||||
"used_quota_in_percent": used_quota_in_percent,
|
|
||||||
"allocated_quota": allocated_quota
|
|
||||||
})
|
})
|
||||||
|
if self.object.quota:
|
||||||
|
used_quota = int(
|
||||||
|
Quota.objects.get_domain_usage(self.object) / 1048576)
|
||||||
|
used_quota_in_percent = int(
|
||||||
|
used_quota / float(self.object.quota) * 100)
|
||||||
|
allocated_quota = (
|
||||||
|
self.object.allocated_quota_in_percent - used_quota_in_percent)
|
||||||
|
context.update({
|
||||||
|
"used_quota": used_quota,
|
||||||
|
"used_quota_in_percent": used_quota_in_percent,
|
||||||
|
"allocated_quota": allocated_quota
|
||||||
|
})
|
||||||
for receiver, widgets in result:
|
for receiver, widgets in result:
|
||||||
for widget in widgets:
|
for widget in widgets:
|
||||||
context["templates"][widget["column"]].append(
|
context["templates"][widget["column"]].append(
|
||||||
|
|||||||
Reference in New Issue
Block a user