1
0

implemented get one namespace via interface mthod

This commit is contained in:
konrad
2018-07-12 11:54:55 +02:00
committed by kolaente
parent 6f5cf55e42
commit 868b93dbbc
3 changed files with 28 additions and 1 deletions

View File

@ -21,6 +21,11 @@ func (Namespace) TableName() string {
return "namespaces"
}
// AfterLoad gets the owner
func (n *Namespace) AfterLoad() {
n.Owner, _, _ = GetUserByID(n.OwnerID)
}
// NamespaceRight defines the rights teams can have for namespaces
type NamespaceRight int
@ -108,6 +113,20 @@ func GetNamespaceByID(id int64) (namespace Namespace, err error) {
return namespace, err
}
// ReadOne gets one namespace
func (n *Namespace) ReadOne(id int64) (err error) {
exists, err := x.ID(id).Get(n)
if err != nil {
return
}
if !exists {
return ErrNamespaceDoesNotExist{ID: id}
}
return
}
// ReadAll gets all namespaces a user has access to
func (n *Namespace) ReadAll(doer *User) (interface{}, error) {