mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -146,3 +146,19 @@ class DomainTestCase(ModoTestCase):
|
||||
content = json.loads(response.content)
|
||||
self.assertIn("test.com", content)
|
||||
self.assertIn("test2.com", content)
|
||||
|
||||
def test_domain_detail_view(self):
|
||||
"""Test Domain detail view."""
|
||||
parameters.save_admin(
|
||||
"ENABLE_DOMAIN_LIMITS", "no", app="limits")
|
||||
domain = Domain.objects.get(name="test.com")
|
||||
url = reverse("admin:domain_detail", args=[domain.pk])
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn("Information", response.content)
|
||||
self.assertIn("Administrators", response.content)
|
||||
self.assertNotIn("Resources usage", response.content)
|
||||
parameters.save_admin(
|
||||
"ENABLE_DOMAIN_LIMITS", "yes", app="limits")
|
||||
response = self.client.get(url)
|
||||
self.assertIn("Resources usage", response.content)
|
||||
|
||||
@@ -72,6 +72,8 @@ def create_domain_limits(sender, instance, **kwargs):
|
||||
@receiver(admin_signals.extra_domain_dashboard_widgets)
|
||||
def display_domain_limits(sender, user, domain, **kwargs):
|
||||
"""Display resources usage for domain."""
|
||||
if parameters.get_admin("ENABLE_DOMAIN_LIMITS") == "no":
|
||||
return []
|
||||
return [{
|
||||
"column": "right",
|
||||
"template": "limits/domain_resources_widget.html",
|
||||
|
||||
Reference in New Issue
Block a user