Added an endpoint to update a team <-> namespace relation
This commit is contained in:
parent
aa40ab8eed
commit
067672dcb4
6 changed files with 58 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
16
models/team_namespace_update.go
Normal file
16
models/team_namespace_update.go
Normal 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
|
||||
}
|
||||
Reference in a new issue