1
0

Added an endpoint to update a team <-> namespace relation

This commit is contained in:
kolaente
2018-09-19 08:16:04 +02:00
parent aa40ab8eed
commit 067672dcb4
6 changed files with 58 additions and 1 deletions

View File

@ -1,6 +1,6 @@
package models
// Update updates a user <-> namespace relation
// Update updates a team <-> list relation
func (tl *TeamList) Update() (err error) {
// Check if the right is valid

View File

@ -11,3 +11,9 @@ func (tn *TeamNamespace) CanDelete(user *User) bool {
n, _ := GetNamespaceByID(tn.NamespaceID)
return n.IsAdmin(user)
}
// CanUpdate checks if a user can update a team from a namespace. Only namespace admins can do that.
func (tn *TeamNamespace) CanUpdate(user *User) bool {
n, _ := GetNamespaceByID(tn.NamespaceID)
return n.IsAdmin(user)
}

View File

@ -0,0 +1,16 @@
package models
// Update updates a team <-> namespace relation
func (tl *TeamNamespace) Update() (err error) {
// Check if the right is valid
if err := tl.Right.isValid(); err != nil {
return err
}
_, err = x.
Where("namespace_id = ? AND team_id = ?", tl.TeamID, tl.TeamID).
Cols("right").
Update(tl)
return
}