airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] branch master updated: AIRAVATA-2711 DRF and JS service to add/remove group admins
Date Fri, 09 Mar 2018 23:18:48 GMT
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 2145c3a  AIRAVATA-2711 DRF and JS service to add/remove group admins
2145c3a is described below

commit 2145c3a9ed86c5e8fe6c20e27990fc0f359cda08
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Fri Mar 9 18:18:33 2018 -0500

    AIRAVATA-2711 DRF and JS service to add/remove group admins
---
 .../django_airavata_api/js/services/GroupService.js     | 16 ++++++++++++++++
 django_airavata/apps/api/views.py                       | 17 +++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/django_airavata/apps/api/static/django_airavata_api/js/services/GroupService.js
b/django_airavata/apps/api/static/django_airavata_api/js/services/GroupService.js
index c34dd9a..3a7685e 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/services/GroupService.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/services/GroupService.js
@@ -41,6 +41,22 @@ class GroupService {
         return FetchUtils.delete('/api/groups/'
                                  + encodeURIComponent(groupId) + '/');
     }
+
+    // adminIds is an array of sharing user ids, for example:
+    //   ['user1@test-domain', 'user2@test-domain']
+    addAdmins(groupId, adminIds) {
+        return FetchUtils.post('/api/groups/'
+                                 + encodeURIComponent(groupId) + '/add_admins/',
+                               JSON.stringify(adminIds));
+    }
+
+    // adminIds is an array of sharing user ids, for example:
+    //   ['user1@test-domain', 'user2@test-domain']
+    removeAdmins(groupId, adminIds) {
+        return FetchUtils.post('/api/groups/'
+                                 + encodeURIComponent(groupId) + '/remove_admins/',
+                               JSON.stringify(adminIds));
+    }
 }
 
 // Export as a singleton
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 61d1576..bbe898f 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -29,6 +29,7 @@ from airavata.model.credential.store.ttypes import CredentialOwnerType,SummaryTy
 from airavata.model.application.io.ttypes import DataType
 
 from collections import OrderedDict
+import json
 import logging
 import os
 
@@ -232,6 +233,22 @@ class GroupViewSet(APIBackedViewSet):
         group_manager_client.deleteGroup(
             self.authz_token, group.id, group.ownerId)
 
+    @detail_route(methods=['post'])
+    def add_admins(self, request, group_id=None):
+        admin_ids = request.data
+        group_manager_client = self.request.profile_service['group_manager']
+        result = group_manager_client.addGroupAdmins(
+            self.authz_token, group_id, admin_ids)
+        return Response({'success': result})
+
+    @detail_route(methods=['post'])
+    def remove_admins(self, request, group_id=None):
+        admin_ids = request.data
+        group_manager_client = self.request.profile_service['group_manager']
+        result = group_manager_client.removeGroupAdmins(
+            self.authz_token, group_id, admin_ids)
+        return Response({'success': result})
+
 
 class ProjectViewSet(APIBackedViewSet):
 

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

Mime
View raw message