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

Handle admin list #181

Merged
merged 2 commits into from
Jul 23, 2024
Merged
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
17 changes: 8 additions & 9 deletions R/new_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#' @param name Name of the project/study.
#' @param pi Name of the principal investigator.
#' @param lead Name(s) of the project lead/data coordinator, comma-sep if multiple, e.g. "Jane Doe, John Doe".
#' @param admin_user (Optional) Synapse username of specified user to be made admin.
#' Currently, only takes one admin user, and the rest can be added via the UI.
#' @param admin_user (Optional) Single id or list of ids of users to be made admin(s).
#' @param abstract Project abstract/description.
#' @param institution Affiliated institution(s), **semicolon-sep if multiple**, e.g. "Stanford University; University of California, San Francisco".
#' @param funder The funding agency. The relevant funder team will be made admin.
Expand Down Expand Up @@ -66,13 +65,13 @@ new_project <- function(name,

# Set project lead/pi user to full admin user if given
if(!is.null(admin_user)) {
user_sharing <- make_admin(project, admin_user)
user_sharing <- lapply(admin_user, function(user) make_admin(project, user))
}

if(publicview) {
public_sharing <- make_public_viewable(project)
}

# ASSETS ---------------------------------------------------------------------#
# Create default upper-level folders
folders <- add_default_folders(project)
Expand Down Expand Up @@ -179,11 +178,11 @@ make_admin <- function(entity, principal_id) {
#' @return A list of the created folder object(s).
#' @export
#' @examples
#' \dontrun{
#' \dontrun{
#' datasets <- list("sequencing data", "imaging data")
#' assays <- c("rnaSeq", "immunohistochemistry")
#' for(i in seq_along(datasets)) attr(datasets[[i]], "assay") <- assays[[i]]
#' make_folder(parent = "syn26462036", datasets)
#' for(i in seq_along(datasets)) attr(datasets[[i]], "assay") <- assays[[i]]
#' make_folder(parent = "syn26462036", datasets)
#'}
make_folder <- function(parent, folders) {

Expand Down Expand Up @@ -251,7 +250,7 @@ add_default_folders <- function(project, folders = c("Analysis", "Milestone Repo
#' @keywords internal
is_valid_user <- function(id) {
status <- tryCatch(
.syn$getUserProfile(id), error = function(e) return(NULL)
.syn$getUserProfile(id), error = function(e) return(NULL)
)
if(length(status)) return(TRUE) else return(FALSE)
}
Expand All @@ -260,7 +259,7 @@ is_valid_user <- function(id) {
#' @keywords internal
is_valid_team <- function(id) {
status <- tryCatch(
.syn$getTeam(id), error = function(e) return(NULL)
.syn$getTeam(id), error = function(e) return(NULL)
)
if(length(status)) return(TRUE) else return(FALSE)
}
Expand Down
Loading