vikunja-api/models/teams_create.go

21 lines
383 B
Go
Raw Normal View History

2018-07-14 17:34:59 +02:00
package models
2018-07-14 17:37:46 +02:00
// Create is the handler to create a team
2018-07-14 17:34:59 +02:00
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
}