This commit is contained in:
konrad 2018-07-14 17:36:17 +02:00 committed by kolaente
parent e1c58843e9
commit bc0e6da602
Signed by untrusted user: konrad
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