Added an endpoint to update a team <-> list relation
This commit is contained in:
parent
5e8597699d
commit
aa40ab8eed
4 changed files with 33 additions and 1 deletions
|
@ -41,7 +41,7 @@ Authorization: Bearer {{auth_token}}
|
||||||
###
|
###
|
||||||
|
|
||||||
# Give a team access to that list
|
# Give a team access to that list
|
||||||
PUT http://localhost:8080/api/v1/lists/10/teams
|
PUT http://localhost:8080/api/v1/lists/1/teams
|
||||||
Authorization: Bearer {{auth_token}}
|
Authorization: Bearer {{auth_token}}
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
|
@ -49,6 +49,15 @@ Content-Type: application/json
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
# Update a teams access to that list
|
||||||
|
POST http://localhost:8080/api/v1/lists/1/teams/2
|
||||||
|
Authorization: Bearer {{auth_token}}
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{"right": 0}
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
# Delete a team from a list
|
# Delete a team from a list
|
||||||
DELETE http://localhost:8080/api/v1/lists/10235/teams/1
|
DELETE http://localhost:8080/api/v1/lists/10235/teams/1
|
||||||
Authorization: Bearer {{auth_token}}
|
Authorization: Bearer {{auth_token}}
|
||||||
|
|
|
@ -11,3 +11,9 @@ func (tl *TeamList) CanDelete(user *User) bool {
|
||||||
l, _ := GetListByID(tl.ListID)
|
l, _ := GetListByID(tl.ListID)
|
||||||
return l.IsAdmin(user)
|
return l.IsAdmin(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanUpdate checks if the user can update a team <-> list relation
|
||||||
|
func (tl *TeamList) CanUpdate(user *User) bool {
|
||||||
|
l, _ := GetListByID(tl.ListID)
|
||||||
|
return l.IsAdmin(user)
|
||||||
|
}
|
||||||
|
|
16
models/team_list_update.go
Normal file
16
models/team_list_update.go
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
// Update updates a user <-> namespace relation
|
||||||
|
func (tl *TeamList) Update() (err error) {
|
||||||
|
|
||||||
|
// Check if the right is valid
|
||||||
|
if err := tl.Right.isValid(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = x.
|
||||||
|
Where("list_id = ? AND team_id = ?", tl.ListID, tl.TeamID).
|
||||||
|
Cols("right").
|
||||||
|
Update(tl)
|
||||||
|
return
|
||||||
|
}
|
|
@ -93,6 +93,7 @@ func RegisterRoutes(e *echo.Echo) {
|
||||||
a.GET("/lists/:list/teams", listTeamHandler.ReadAllWeb)
|
a.GET("/lists/:list/teams", listTeamHandler.ReadAllWeb)
|
||||||
a.PUT("/lists/:list/teams", listTeamHandler.CreateWeb)
|
a.PUT("/lists/:list/teams", listTeamHandler.CreateWeb)
|
||||||
a.DELETE("/lists/:list/teams/:team", listTeamHandler.DeleteWeb)
|
a.DELETE("/lists/:list/teams/:team", listTeamHandler.DeleteWeb)
|
||||||
|
a.POST("/lists/:list/teams/:team", listTeamHandler.UpdateWeb)
|
||||||
|
|
||||||
listUserHandler := &crud.WebHandler{
|
listUserHandler := &crud.WebHandler{
|
||||||
CObject: &models.ListUser{},
|
CObject: &models.ListUser{},
|
||||||
|
|
Loading…
Add table
Reference in a new issue