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/06/27 15:56:35 UTC

[airavata-django-portal] branch master updated: AIRAVATA-2934 Support selective enabling of app's nav item

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


The following commit(s) were added to refs/heads/master by this push:
     new fd12e08  AIRAVATA-2934 Support selective enabling of app's nav item
fd12e08 is described below

commit fd12e08f950f8f0e600c194c474bc1a39368b8d6
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Thu Jun 27 11:56:05 2019 -0400

    AIRAVATA-2934 Support selective enabling of app's nav item
---
 django_airavata/apps/admin/apps.py    | 14 ++++++++++----
 django_airavata/context_processors.py |  5 ++++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/django_airavata/apps/admin/apps.py b/django_airavata/apps/admin/apps.py
index 93cb6e4..87ab0ba 100644
--- a/django_airavata/apps/admin/apps.py
+++ b/django_airavata/apps/admin/apps.py
@@ -17,19 +17,24 @@ class AdminConfig(AiravataAppConfig):
             'label': 'Application Catalog',
             'icon': 'fa fa-cogs',
             'url': 'django_airavata_admin:app_catalog',
-            'active_prefixes': ['applications']
+            'active_prefixes': ['applications'],
+            'enabled': lambda req: (req.is_gateway_admin or
+                                    req.is_read_only_gateway_admin),
         },
         {
             'label': 'Manage Users',
             'icon': 'fa fa-users',
             'url': 'django_airavata_admin:users',
-            'active_prefixes': ['users']
+            'active_prefixes': ['users'],
+            'enabled': lambda req: req.is_gateway_admin,
         },
         {
             'label': 'Experiment Statistics',
             'icon': 'fa fa-chart-bar',
             'url': 'django_airavata_admin:experiment-statistics',
-            'active_prefixes': ['experiment-statistics']
+            'active_prefixes': ['experiment-statistics'],
+            'enabled': lambda req: (req.is_gateway_admin or
+                                    req.is_read_only_gateway_admin),
         },
         {
             'label': 'Credential Store',
@@ -47,6 +52,7 @@ class AdminConfig(AiravataAppConfig):
             'label': 'Gateway Resource Profile',
             'icon': 'fa fa-tasks',
             'url': 'django_airavata_admin:gateway_resource_profile',
-            'active_prefixes': ['gateway-resource-profile']
+            'active_prefixes': ['gateway-resource-profile'],
+            'enabled': lambda req: req.is_gateway_admin
         },
     ]
diff --git a/django_airavata/context_processors.py b/django_airavata/context_processors.py
index 8e61532..ead6917 100644
--- a/django_airavata/context_processors.py
+++ b/django_airavata/context_processors.py
@@ -52,7 +52,10 @@ def _get_current_app(request, apps):
 
 def _get_app_nav(request, current_app):
     if hasattr(current_app, 'nav'):
-        nav = copy.copy(current_app.nav)
+        # Copy and filter current_app's nav items
+        nav = [item
+               for item in copy.copy(current_app.nav)
+               if 'enabled' not in item or item['enabled'](request)]
         # convert "/djangoapp/path/in/app" to "path/in/app"
         app_path = "/".join(request.path.split("/")[2:])
         for nav_item in nav: