Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /admin/communities endpoints for admin App Community management. #73

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/terrain/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
(admin-app-comment-routes)
(admin-app-community-routes)
(admin-comment-routes)
(admin-community-routes)
(admin-filesystem-metadata-routes)
(admin-groups-routes)
(admin-notification-routes)
Expand Down
29 changes: 29 additions & 0 deletions src/terrain/routes/collaborator.clj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,35 @@
(POST "/communities/:name/admins/deleter" [name :as {:keys [body]}]
(service/success-response (communities/remove-community-admins current-user name (service/decode-json body))))))

(defn admin-community-routes
[]
(optional-routes
[config/collaborator-routes-enabled]

(GET "/communities" [:as {:keys [params]}]
(service/success-response (communities/admin-get-communities params)))

(POST "/communities" [:as {:keys [body]}]
(service/success-response (communities/add-community current-user (service/decode-json body))))

(GET "/communities/:name" [name]
(service/success-response (communities/admin-get-community name)))

(PATCH "/communities/:name" [name :as {:keys [body]}]
(service/success-response (communities/admin-update-community name (service/decode-json body))))

(DELETE "/communities/:name" [name]
(service/success-response (communities/admin-delete-community name)))

(GET "/communities/:name/admins" [name]
(service/success-response (communities/admin-get-community-admins name)))

(POST "/communities/:name/admins" [name :as {:keys [body]}]
(service/success-response (communities/admin-add-community-admins name (service/decode-json body))))

(POST "/communities/:name/admins/deleter" [name :as {:keys [body]}]
(service/success-response (communities/admin-remove-community-admins name (service/decode-json body))))))

(defn subject-routes
[]
(optional-routes
Expand Down
24 changes: 23 additions & 1 deletion src/terrain/services/communities.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(ns terrain.services.communities
(:require [terrain.clients.iplant-groups :as ipg]
[terrain.clients.permissions :as perms-client]
[terrain.clients.notifications :as cn]))
[terrain.clients.notifications :as cn]
[terrain.util.config :as config]))

(defn get-communities [{user :shortUsername} params]
(ipg/get-communities user (select-keys params [:search :creator :member])))
Expand Down Expand Up @@ -32,3 +33,24 @@

(defn remove-community-admins [{user :shortUsername} name {:keys [members]}]
(ipg/remove-community-admins user name members))

(defn admin-get-communities [params]
(get-communities {:shortUsername (config/grouper-user)} params))

(defn admin-get-community [name]
(get-community {:shortUsername (config/grouper-user)} name))

(defn admin-update-community [name body]
(update-community {:shortUsername (config/grouper-user)} name body))

(defn admin-delete-community [name]
(delete-community {:shortUsername (config/grouper-user)} name))

(defn admin-get-community-admins [name]
(get-community-admins {:shortUsername (config/grouper-user)} name))

(defn admin-add-community-admins [name params]
(add-community-admins {:shortUsername (config/grouper-user)} name params))

(defn admin-remove-community-admins [name params]
(remove-community-admins {:shortUsername (config/grouper-user)} name params))