1
0

implemented creation of thing via parambinder

This commit is contained in:
konrad
2018-07-18 08:56:19 +02:00
committed by kolaente
parent ebb5b332b6
commit de95ff40bf
21 changed files with 39 additions and 40 deletions

View File

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