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-2694 Implemented GroupService.delete()
Date Tue, 27 Feb 2018 22:05:45 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 82a1fe4  AIRAVATA-2694 Implemented GroupService.delete()
82a1fe4 is described below

commit 82a1fe44d212ceff54e174a50c6afb54a721153b
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Tue Feb 27 17:05:24 2018 -0500

    AIRAVATA-2694 Implemented GroupService.delete()
---
 .../django_airavata_api/js/services/GroupService.js   |  5 +++++
 .../static/django_airavata_api/js/utils/FetchUtils.js | 19 +++++++++++++++++++
 django_airavata/apps/api/views.py                     |  5 +++++
 3 files changed, 29 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 5ca6e9d..c34dd9a 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
@@ -36,6 +36,11 @@ class GroupService {
                 .then(result => new Group(result));
         }
     }
+
+    delete(groupId) {
+        return FetchUtils.delete('/api/groups/'
+                                 + encodeURIComponent(groupId) + '/');
+    }
 }
 
 // Export as a singleton
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/utils/FetchUtils.js b/django_airavata/apps/api/static/django_airavata_api/js/utils/FetchUtils.js
index 58027f0..d22926c 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/utils/FetchUtils.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/utils/FetchUtils.js
@@ -85,4 +85,23 @@ export default {
             }
         })
     },
+    delete: function(url) {
+        var headers = this.createHeaders()
+        return fetch(url, {
+            method: 'delete',
+            headers: headers,
+            credentials: "same-origin"
+        }).then((response) => {
+            // Not expecting a response body
+            if (response.ok && response.status === 204) {
+                return Promise.resolve();
+            } else {
+                let error = new Error(response.statusText);
+                return response.json().then(json => {
+                    error.data = json;
+                })
+                .then(() => Promise.reject(error),() => Promise.reject(error));
+            }
+        })
+    }
 }
\ No newline at end of file
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index ecfba8b..61d1576 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -227,6 +227,11 @@ class GroupViewSet(APIBackedViewSet):
                 self.authz_token, group._removed_members, group.id)
         group_manager_client.updateGroup(self.authz_token, group)
 
+    def perform_destroy(self, group):
+        group_manager_client = self.request.profile_service['group_manager']
+        group_manager_client.deleteGroup(
+            self.authz_token, group.id, group.ownerId)
+
 
 class ProjectViewSet(APIBackedViewSet):
 

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

Mime
View raw message