1
0

implemented team create method

This commit is contained in:
konrad
2018-07-14 17:34:59 +02:00
committed by kolaente
parent 376c649a12
commit e1c58843e9
8 changed files with 108 additions and 22 deletions

19
models/teams_create.go Normal file
View File

@ -0,0 +1,19 @@
package models
func (t *Team) Create(doer *User, _ int64) (err error) {
// Check if we have a name
if t.Name == "" {
return ErrTeamNameCannotBeEmpty{}
}
// Set the id to 0, otherwise the creation fails because of double keys
t.CreatedByID = doer.ID
t.CreatedBy = doer
_, err = x.Insert(t)
if err != nil {
return
}
return
}