From b21207954567a7e0b35b6bc1a3d07d5c437ed829 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Tue, 18 Jun 2024 09:43:38 -0500 Subject: [PATCH] Bugs/DES-2907: Exclude allocations at portal level (#1302) * Bug/DES-2907: Allow exclusions from allocations at portal level * Fix formatting * Use env for settings --- conf/env_files/designsafe.sample.env | 6 ++++++ designsafe/apps/workspace/api/views.py | 7 +++++++ designsafe/settings/common_settings.py | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/conf/env_files/designsafe.sample.env b/conf/env_files/designsafe.sample.env index 82511fdb70..5c13942f68 100644 --- a/conf/env_files/designsafe.sample.env +++ b/conf/env_files/designsafe.sample.env @@ -25,6 +25,12 @@ TAS_CLIENT_KEY= TAS_CLIENT_SECRET= TAS_URL= +### +# ALLOCATION +# Add any allocation to exclude only from portal +# This will be a comma separated list. +ALLOCATIONS_TO_EXCLUDE= + ### # EMAIL # diff --git a/designsafe/apps/workspace/api/views.py b/designsafe/apps/workspace/api/views.py index 6094b4a24c..f53209422d 100644 --- a/designsafe/apps/workspace/api/views.py +++ b/designsafe/apps/workspace/api/views.py @@ -879,6 +879,13 @@ def get(self, request): : rtype: dict """ data = self._get_allocations(request.user) + # Exclude allocation based on allocation setting list. + for host, allocations in data["hosts"].items(): + data["hosts"][host] = [ + allocation + for allocation in allocations + if allocation not in settings.ALLOCATIONS_TO_EXCLUDE + ] return JsonResponse( { diff --git a/designsafe/settings/common_settings.py b/designsafe/settings/common_settings.py index bb5a34303c..c75380effc 100644 --- a/designsafe/settings/common_settings.py +++ b/designsafe/settings/common_settings.py @@ -499,6 +499,11 @@ TAS_CLIENT_SECRET = os.environ.get('TAS_CLIENT_SECRET', None) TAS_URL = os.environ.get('TAS_URL', None) +# Allocations to exclude +# +ALLOCATIONS_TO_EXCLUDE = os.environ.get("ALLOCATIONS_TO_EXCLUDE", "").split(",") if os.environ.get("ALLOCATIONS_TO_EXCLUDE") else [] + + ### # Agave Integration #