Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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,
"created" -> space.created.toString))
}

def userToJson(user: User) = {
toJson(Map("id" -> user.id.stringify,
"email" -> user.email.get
))
}


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