cleanup
This commit is contained in:
parent
e1c58843e9
commit
bc0e6da602
3 changed files with 21 additions and 20 deletions
21
models/namespace_create.go
Normal file
21
models/namespace_create.go
Normal 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
|
||||||
|
}
|
|
@ -1,25 +1,5 @@
|
||||||
package models
|
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
|
// Update implements the update method via the interface
|
||||||
func (n *Namespace) Update(id int64) (err error) {
|
func (n *Namespace) Update(id int64) (err error) {
|
||||||
// Check if we have at least a name
|
// Check if we have at least a name
|
Loading…
Reference in a new issue