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

adding creator to space json returned, adding route for users in space #453

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions app/api/Spaces.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ class Spaces @Inject()(spaces: SpaceService,
case None => NotFound("Space not found")
}
}
def getUsers(id: UUID) = PermissionAction(Permission.ViewSpace, Some(ResourceRef(ResourceRef.space, id))) { implicit request =>
spaces.get(id) match {
case Some(space) =>
val usersInSpace = spaces.getUsersInSpace(space.id, None)
Ok(toJson(usersInSpace.map(userToJson)))
case None => {
NotFound("Space not found")
}
}
}

def list(when: Option[String], title: Option[String], date: Option[String], limit: Int) = UserAction(needActive=false) { implicit request =>
Ok(toJson(listSpaces(when, title, date, limit, Set[Permission](Permission.ViewSpace), false, request.user, request.user.fold(false)(_.superAdminMode), true).map(spaceToJson)))
Expand Down Expand Up @@ -167,9 +177,17 @@ class Spaces @Inject()(spaces: SpaceService,
toJson(Map("id" -> space.id.stringify,
"name" -> space.name,
"description" -> space.description,
"creator" -> space.creator.stringify,
longshuicy marked this conversation as resolved.
Show resolved Hide resolved
"created" -> space.created.toString))
}

def userToJson(user: User) = {
toJson(Map("id" -> user.id.stringify,
"email" -> user.email.get
))
}
longshuicy marked this conversation as resolved.
Show resolved Hide resolved


def addCollectionToSpace(spaceId: UUID, collectionId: UUID) = PermissionAction(Permission.AddResourceToSpace, Some(ResourceRef(ResourceRef.space, spaceId))) {
implicit request =>
(spaces.get(spaceId), collectionService.get(collectionId)) match {
Expand Down
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ GET /api/files/:three_d_file_id/:filename
GET /api/spaces @api.Spaces.list(when: Option[String] ?= None, title: Option[String] ?= None, date: Option[String] ?= None, limit: Int ?= 12)
GET /api/spaces/canEdit @api.Spaces.listCanEdit(when: Option[String] ?= None, title: Option[String] ?= None, date: Option[String] ?= None, limit: Int ?= 12)
GET /api/spaces/:id @api.Spaces.get(id: UUID)
GET /api/spaces/:id/users @api.Spaces.getUsers(id: UUID)
POST /api/spaces @api.Spaces.createSpace()
DELETE /api/spaces/:id @api.Spaces.removeSpace(id: UUID)
POST /api/spaces/:spaceId/removeCollection/:collectionId @api.Spaces.removeCollection(spaceId: UUID, collectionId: UUID, removeDatasets : Boolean)
Expand Down
Loading