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 @@

{% if not groups_dict %}

- No need to manage the customers of the app on Control panel as it does not require authentication + Customer management is disabled. To manage customers, create an Auth0 client and enable authentication on the manage app page.

{% else %}
diff --git a/controlpanel/frontend/jinja2/includes/app-list.html b/controlpanel/frontend/jinja2/includes/app-list.html index 64d6d45d3..c210b1bb6 100644 --- a/controlpanel/frontend/jinja2/includes/app-list.html +++ b/controlpanel/frontend/jinja2/includes/app-list.html @@ -36,12 +36,9 @@ {{ yes_no(user.is_app_admin(app.id)) }} - {% if app.can_manage_customers %} - - Manage customers - - {% endif %} + + Manage customers + diff --git a/tests/api/models/test_app.py b/tests/api/models/test_app.py index 453f06322..c9132c5b0 100644 --- a/tests/api/models/test_app.py +++ b/tests/api/models/test_app.py @@ -209,17 +209,3 @@ def test_app_allowed_ip_ranges(): def test_iam_role_arn(): app = App(slug="example-app") assert app.iam_role_arn == f"arn:aws:iam::{settings.AWS_DATA_ACCOUNT_ID}:role/test_app_example-app" - - -@pytest.mark.parametrize("conf, expected", [ - (None, False), - ({}, False), - ({"some_setting_key": []}, False), - ({App.KEY_WORD_FOR_AUTH_SETTINGS: None}, False), - ({App.KEY_WORD_FOR_AUTH_SETTINGS: {}}, False), - ({App.KEY_WORD_FOR_AUTH_SETTINGS: {"dev": {}}}, True), -]) -def test_can_manage_customers(conf, expected): - app = App() - app.app_conf = conf - assert app.can_manage_customers is expected