1
0

implemented read all method for namespace teams

This commit is contained in:
konrad
2018-07-18 22:06:29 +02:00
parent 6618874441
commit 935c99be45
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package models
func (tn *TeamNamespace) ReadAll(user *User) (interface{}, error) {
// Check if the user can read the namespace
n, err := GetNamespaceByID(tn.NamespaceID)
if err != nil {
return nil, err
}
if !n.CanRead(user) {
return nil, ErrNeedToHaveNamespaceReadAccess{NamespaceID:tn.NamespaceID, UserID:user.ID}
}
// Get the teams
all := []*Team{}
err = x.Select("teams.*").
Table("teams").
Join("INNER", "team_namespaces", "team_id = teams.id").
Where("team_namespaces.namespace_id = ?", tn.NamespaceID).
Find(&all)
return all, err
}