This commit is contained in:
konrad 2018-07-14 17:36:17 +02:00 committed by kolaente
parent e1c58843e9
commit bc0e6da602
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 21 additions and 20 deletions

View file

@ -0,0 +1,21 @@
package models
// Create implements the creation method via the interface
func (n *Namespace) Create(doer *User, _ int64) (err error) {
// Check if we have at least a name
if n.Name == "" {
return ErrNamespaceNameCannotBeEmpty{NamespaceID: 0, UserID: doer.ID}
}
n.ID = 0 // This would otherwise prevent the creation of new lists after one was created
// Check if the User exists
n.Owner, _, err = GetUserByID(doer.ID)
if err != nil {
return
}
n.OwnerID = n.Owner.ID
// Insert
_, err = x.Insert(n)
return
}

View file

@ -1,25 +1,5 @@
package models
// Create implements the creation method via the interface
func (n *Namespace) Create(doer *User, _ int64) (err error) {
// Check if we have at least a name
if n.Name == "" {
return ErrNamespaceNameCannotBeEmpty{NamespaceID: 0, UserID: doer.ID}
}
n.ID = 0 // This would otherwise prevent the creation of new lists after one was created
// Check if the User exists
n.Owner, _, err = GetUserByID(doer.ID)
if err != nil {
return
}
n.OwnerID = n.Owner.ID
// Insert
_, err = x.Insert(n)
return
}
// Update implements the update method via the interface
func (n *Namespace) Update(id int64) (err error) {
// Check if we have at least a name