You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/07/26 15:15:27 UTC
[airavata-django-portal] 03/03: AIRAVATA-3177 Only allow admins to
see Data Parsers
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit dee1f6fe08acc4ea0c67bb0002673efd371343c2
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri Jul 26 11:14:38 2019 -0400
AIRAVATA-3177 Only allow admins to see Data Parsers
---
django_airavata/apps/dataparsers/apps.py | 3 +++
django_airavata/context_processors.py | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/django_airavata/apps/dataparsers/apps.py b/django_airavata/apps/dataparsers/apps.py
index 834e2ec..836b34e 100644
--- a/django_airavata/apps/dataparsers/apps.py
+++ b/django_airavata/apps/dataparsers/apps.py
@@ -19,3 +19,6 @@ class DataParsersConfig(AiravataAppConfig):
'url': 'django_airavata_dataparsers:home',
},
]
+
+ def enabled(self, request):
+ return getattr(request, 'is_gateway_admin', False)
diff --git a/django_airavata/context_processors.py b/django_airavata/context_processors.py
index 4d5f16a..1398e28 100644
--- a/django_airavata/context_processors.py
+++ b/django_airavata/context_processors.py
@@ -77,6 +77,9 @@ def airavata_app_registry(request):
"""Put airavata django apps into the context."""
airavata_apps = [app for app in apps.get_app_configs()
if isinstance(app, AiravataAppConfig) and
+ (getattr(app, 'enabled', None) is None or
+ app.enabled(request)
+ ) and
app.label not in settings.HIDDEN_AIRAVATA_APPS]
# Sort by app_order then by verbose_name (case-insensitive)
airavata_apps.sort(
@@ -95,6 +98,10 @@ def airavata_app_registry(request):
def custom_app_registry(request):
"""Put custom Django apps into the context."""
custom_apps = settings.CUSTOM_DJANGO_APPS.copy()
+ custom_apps = [app for app in custom_apps
+ if (getattr(app, 'enabled', None) is None or
+ app.enabled(request)
+ )]
custom_apps.sort(key=lambda app: app.verbose_name.lower())
current_custom_app = _get_current_app(request, custom_apps)
return {