1
0

implemented create team <-> namespace relation

This commit is contained in:
konrad
2018-07-17 08:44:21 +02:00
committed by kolaente
parent 2e3c10be13
commit 7feb82702d
8 changed files with 80 additions and 17 deletions

View File

@ -0,0 +1,27 @@
package models
// Create creates a new team <-> namespace relation
func (tn *TeamNamespace) Create(doer *User, nID int64) (err error) {
// Check if the rights are valid
if tn.Right != NamespaceRightAdmin && tn.Right != NamespaceRightRead && tn.Right != NamespaceRightWrite {
return ErrInvalidTeamRight{tn.Right}
}
// Check if the team exists
_, err = GetTeamByID(tn.TeamID)
if err != nil {
return
}
// Check if the namespace exists
_, err = GetNamespaceByID(nID)
if err != nil {
return
}
tn.NamespaceID = nID
// Insert the new team
_, err = x.Insert(tn)
return
}