implemented viewing all teams of a list
This commit is contained in:
parent
edf9b6f2c7
commit
227a2afd37
1 changed files with 24 additions and 0 deletions
24
models/team_list_readall.go
Normal file
24
models/team_list_readall.go
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
// ReadAll implements the method to read all teams of a namespace
|
||||||
|
func (tl *TeamList) ReadAll(user *User) (interface{}, error) {
|
||||||
|
// Check if the user can read the namespace
|
||||||
|
l, err := GetListByID(tl.ListID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !l.CanRead(user) {
|
||||||
|
return nil, ErrNeedToHaveListReadAccess{ListID: tl.ListID, UserID: user.ID}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the teams
|
||||||
|
all := []*Team{}
|
||||||
|
|
||||||
|
err = x.Select("teams.*").
|
||||||
|
Table("teams").
|
||||||
|
Join("INNER", "team_list", "team_id = teams.id").
|
||||||
|
Where("team_list.list_id = ?", tl.ListID).
|
||||||
|
Find(&all)
|
||||||
|
|
||||||
|
return all, err
|
||||||
|
}
|
Loading…
Reference in a new issue