implemented deletomg a team from a list
This commit is contained in:
parent
227a2afd37
commit
9638f36788
2 changed files with 31 additions and 1 deletions
24
models/team_list_delete.go
Normal file
24
models/team_list_delete.go
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
// Delete deletes a team <-> list relation based on the list & team id
|
||||||
|
func (tl *TeamList) Delete() (err error) {
|
||||||
|
|
||||||
|
// Check if the list exists
|
||||||
|
_, err = GetListByID(tl.ListID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the team exists
|
||||||
|
_, err = GetTeamByID(tl.TeamID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the relation
|
||||||
|
_, err = x.Where("team_id = ?", tl.TeamID).
|
||||||
|
And("list_id = ?", tl.ListID).
|
||||||
|
Delete(TeamList{})
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,7 +1,13 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
// CanCreate checks if the use can create a team <-> list relation
|
// CanCreate checks if the user can create a team <-> list relation
|
||||||
func (tl *TeamList) CanCreate(user *User) bool {
|
func (tl *TeamList) CanCreate(user *User) bool {
|
||||||
l, _ := GetListByID(tl.ListID)
|
l, _ := GetListByID(tl.ListID)
|
||||||
return l.IsAdmin(user)
|
return l.IsAdmin(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanDelete checks if the user can delete a team <-> list relation
|
||||||
|
func (tl *TeamList) CanDelete(user *User) bool {
|
||||||
|
l, _ := GetListByID(tl.ListID)
|
||||||
|
return l.IsAdmin(user)
|
||||||
|
}
|
Loading…
Reference in a new issue