1
0

Implemented team delete method

This commit is contained in:
konrad
2018-07-16 08:18:15 +02:00
committed by kolaente
parent 4cf0cd233c
commit 8a06db5351
3 changed files with 51 additions and 0 deletions

View File

@ -17,3 +17,18 @@ func (t *Team) CanUpdate(user *User, id int64) bool {
return exists
}
// CanDelete
func (t *Team) CanDelete(user *User, id int64) bool {
t.ID = id
return t.IsAdmin(user)
}
// IsAdmin
func (t *Team) IsAdmin(user *User) bool {
exists, _ := x.Where("team_id = ?", t.ID).
And("user_id = ?", user.ID).
And("is_admin = ?", true).
Get(&TeamMember{})
return exists
}