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 9aa0d74 AIRAVATA-2855 Make Gateway Admins Django superusers so they
can edit CMS
9aa0d74 is described below
commit 9aa0d7410f2bc8bd11d77653ce6966fc3f8d252d
Author: Marcus Christie <[email protected]>
AuthorDate: Thu Jul 19 10:09:58 2018 -0400
AIRAVATA-2855 Make Gateway Admins Django superusers so they can edit CMS
---
django_airavata/apps/auth/middleware.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/django_airavata/apps/auth/middleware.py
b/django_airavata/apps/auth/middleware.py
index 54182b1..954f137 100644
--- a/django_airavata/apps/auth/middleware.py
+++ b/django_airavata/apps/auth/middleware.py
@@ -55,6 +55,11 @@ def gateway_groups_middleware(get_response):
request.is_gateway_admin = admins_group_id in group_ids
request.is_read_only_gateway_admin = \
read_only_admins_group_id in group_ids
+ # Gateway Admins are made 'superuser' in Django so they can edit
+ # pages in the CMS
+ if request.is_gateway_admin and not request.user.is_superuser:
+ request.user.is_superuser = True
+ request.user.save()
except Exception as e:
log.error("Failed to set is_gateway_admin, "
"is_read_only_gateway_admin for user", exc_info=e)