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 44ca9b1287f63886448a8d222a3fa89261547708 Author: Marcus Christie <[email protected]> AuthorDate: Fri Jul 26 09:26:43 2019 -0400 AIRAVATA-3177 Restrict readonly admins from creating new application --- .../src/components/dashboards/ApplicationsDashboard.vue | 7 +++++-- .../api/static/django_airavata_api/js/session/Session.js | 3 ++- django_airavata/context_processors.py | 13 +++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue index e44b7e7..bf6b3f1 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue @@ -1,6 +1,6 @@ <template> <list-layout @add-new-item="newApplicationHandler" :items="sortedModules" title="Application Catalog" subtitle="Applications" - new-item-button-text="New Application"> + new-item-button-text="New Application" :new-button-disabled="!isGatewayAdmin"> <template slot="item-list" slot-scope="slotProps"> <div class="row"> <application-card v-for="item in slotProps.items" v-bind:app-module="item" v-bind:key="item.appModuleId" v-on:app-selected="clickHandler(item)"> @@ -13,7 +13,7 @@ import { layouts, components as comps } from "django-airavata-common-ui"; -import { services, utils } from "django-airavata-api"; +import { services, session, utils } from "django-airavata-api"; export default { components: { @@ -38,6 +38,9 @@ export default { } else { return []; } + }, + isGatewayAdmin() { + return session.Session.isGatewayAdmin; } }, methods: { diff --git a/django_airavata/apps/api/static/django_airavata_api/js/session/Session.js b/django_airavata/apps/api/static/django_airavata_api/js/session/Session.js index 797fc70..102033e 100644 --- a/django_airavata/apps/api/static/django_airavata_api/js/session/Session.js +++ b/django_airavata/apps/api/static/django_airavata_api/js/session/Session.js @@ -1,7 +1,8 @@ class Session { - init({ username, airavataInternalUserId }) { + init({ username, airavataInternalUserId, isGatewayAdmin = false }) { this.username = username; this.airavataInternalUserId = airavataInternalUserId; + this.isGatewayAdmin = isGatewayAdmin; } } diff --git a/django_airavata/context_processors.py b/django_airavata/context_processors.py index 190b4c6..4d5f16a 100644 --- a/django_airavata/context_processors.py +++ b/django_airavata/context_processors.py @@ -61,12 +61,13 @@ def get_notifications(request): def user_session_data(request): - data = { - "username": request.user.username, - "airavataInternalUserId": (request.user.username + - "@" + - settings.GATEWAY_ID), - } + data = {} + if request.user.is_authenticated: + data["username"] = request.user.username + data["airavataInternalUserId"] = (request.user.username + + "@" + + settings.GATEWAY_ID) + data["isGatewayAdmin"] = request.is_gateway_admin return { "user_session_data": json.dumps(data) }
