1
0

Added endpoint to update a users right for a list

This commit is contained in:
kolaente
2018-09-19 07:54:47 +02:00
parent 3a338f54f9
commit 4f538abc83
4 changed files with 34 additions and 1 deletions

View File

@ -39,3 +39,10 @@ func (lu *ListUser) CanDelete(doer *User) bool {
l, _ := GetListByID(lu.ListID)
return l.CanWrite(doer)
}
// CanUpdate checks if the user can update a user <-> list relation
func (lu *ListUser) CanUpdate(doer *User) bool {
// Get the list and check if the user has write access on it
l, _ := GetListByID(lu.ListID)
return l.CanWrite(doer)
}

View File

@ -0,0 +1,16 @@
package models
// Update updates a user <-> list relation
func (lu *ListUser) Update() (err error) {
// Check if the right is valid
if err := lu.Right.isValid(); err != nil {
return err
}
_, err = x.
Where("list_id = ? AND user_id = ?", lu.ListID, lu.UserID).
Cols("right").
Update(lu)
return
}