Skip to content

Commit

Permalink
cyverse-de#71 Update App Community names created by POST /communities.
Browse files Browse the repository at this point in the history
Updated terrain.clients.iplant-groups/add-community to create community
groups with names formatted like
iplant:de:<env>:communities:<name>
(keeping communities out of the requesting user's namespace).
  • Loading branch information
psarando committed Oct 17, 2018
1 parent 6bf0c6e commit 6cb4f64
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/terrain/clients/iplant_groups.clj
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,28 @@
(defn get-communities [user params]
(get-teams* group-type-communities user params))

(defn- grant-initial-team-privileges [client user group public-privileges]
(defn- grant-initial-team-privileges [client user group initial-admin public-privileges]
(c/update-group-privileges client user group
{:updates [{:subject_id (config/grouper-user) :privileges ["admin"]}
{:updates [{:subject_id initial-admin :privileges ["admin"]}
{:subject_id c/public-user :privileges public-privileges}]}))

(defn- add-team* [team-type user {:keys [name description public_privileges] :or {public_privileges []}}]
(defn add-team [user {:keys [name description public_privileges] :or {public_privileges []}}]
(let [client (get-client)
folder (get-team-folder-name client team-type user)]
(ensure-team-folder-exists client team-type user)
(let [full-name (str folder ":" name)
folder (get-team-folder-name client group-type-teams user)]
(ensure-team-folder-exists client group-type-teams user)
(let [full-name (full-group-name name folder)
group (c/add-group client user full-name team-group-type description)]
(grant-initial-team-privileges client user full-name public_privileges)
(format-group (get-team-folder-name client team-type) group))))
(grant-initial-team-privileges client user full-name (config/grouper-user) public_privileges)
(format-group (get-team-folder-name client group-type-teams) group))))

(defn add-team [user request]
(add-team* group-type-teams user request))

(defn add-community [user request]
(add-team* group-type-communities user request))
(defn add-community [user {:keys [name description public_privileges] :or {public_privileges []}}]
(let [client (get-client)
folder (get-team-folder-name client group-type-communities)]
(ensure-folder-exists client (config/grouper-user) folder)
(let [full-name (full-group-name name folder)
group (c/add-group client (config/grouper-user) full-name team-group-type description)]
(grant-initial-team-privileges client (config/grouper-user) full-name user public_privileges)
(format-group folder group))))

(defn- get-team* [team-type user name]
(let [client (get-client)
Expand Down

0 comments on commit 6cb4f64

Please sign in to comment.