From 34116eed48cba90f83257733deb0d012610c4957 Mon Sep 17 00:00:00 2001 From: Michael Collins <15347726+michaeljcollinsuk@users.noreply.github.com> Date: Fri, 16 Feb 2024 09:33:46 +0000 Subject: [PATCH] Revert changes to hide the 'Manage Customers' button Hiding the button broke formatting on the app list page and could lead to confusion. Instead I have improved the messaging displayed to users if they try to manage customers without either creating an Auth0 client or enabling authentication. --- controlpanel/api/models/app.py | 13 ++++--------- controlpanel/frontend/jinja2/customers-list.html | 2 +- .../frontend/jinja2/includes/app-list.html | 9 +++------ tests/api/models/test_app.py | 14 -------------- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/controlpanel/api/models/app.py b/controlpanel/api/models/app.py index 07533261d..54b270da2 100644 --- a/controlpanel/api/models/app.py +++ b/controlpanel/api/models/app.py @@ -10,10 +10,9 @@ from django_extensions.db.models import TimeStampedModel # First-party/Local -from controlpanel.api import auth0, cluster +from controlpanel.api import auth0, cluster, tasks from controlpanel.api.models import IPAllowlist from controlpanel.utils import github_repository_name, s3_slugify, webapp_release_name -from controlpanel.api import tasks class App(TimeStampedModel): @@ -83,12 +82,6 @@ def release_name(self): def iam_role_arn(self): return cluster.iam_arn(f"role/{self.iam_role_name}") - @property - def can_manage_customers(self): - if not self.app_conf: - return False - return bool(self.app_conf.get(self.KEY_WORD_FOR_AUTH_SETTINGS)) - def get_group_id(self, env_name): return self.get_auth_client(env_name).get("group_id") @@ -320,7 +313,8 @@ class DeleteCustomerError(Exception): App.DeleteCustomerError = DeleteCustomerError -from django.db.models.signals import post_save, post_delete +# Third-party +from django.db.models.signals import post_delete, post_save from django.dispatch import receiver @@ -342,6 +336,7 @@ def trigger_app_create_related_messages(sender, instance, created, **kwargs): @receiver(post_delete, sender=App) def remove_app_related_tasks(sender, instance, **kwargs): + # First-party/Local from controlpanel.api.models import Task related_app_tasks = Task.objects.filter(entity_class="App", entity_id=instance.id) for task in related_app_tasks: diff --git a/controlpanel/frontend/jinja2/customers-list.html b/controlpanel/frontend/jinja2/customers-list.html index 9c3f042a4..f693c9a2f 100644 --- a/controlpanel/frontend/jinja2/customers-list.html +++ b/controlpanel/frontend/jinja2/customers-list.html @@ -20,7 +20,7 @@