Implemented CanDelete method for lists and listitems
This commit is contained in:
@ -3,21 +3,11 @@ package models
|
||||
// Delete implements the delete method of CRUDable
|
||||
func (l *List) Delete(id int64, doer *User) (err error) {
|
||||
// Check if the list exists
|
||||
list, err := GetListByID(id)
|
||||
_, err = GetListByID(id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Check rights
|
||||
user, _, err := GetUserByID(doer.ID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !list.IsAdmin(&user) {
|
||||
return ErrNeedToBeListAdmin{ListID: id, UserID: user.ID}
|
||||
}
|
||||
|
||||
// Delete the list
|
||||
_, err = x.ID(id).Delete(&List{})
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user