Added method to show all lists in a namespace
This commit is contained in:
@ -6,29 +6,30 @@ type List struct {
|
||||
Title string `xorm:"varchar(250)" json:"title"`
|
||||
Description string `xorm:"varchar(1000)" json:"description"`
|
||||
OwnerID int64 `xorm:"int(11)" json:"-"`
|
||||
Owner User `xorm:"-" json:"owner"`
|
||||
NamespaceID int64 `xorm:"int(11)" json:"-"`
|
||||
Created int64 `xorm:"created" json:"created"`
|
||||
Updated int64 `xorm:"updated" json:"updated"`
|
||||
|
||||
Owner User `xorm:"-" json:"owner"`
|
||||
Items []*ListItem `xorm:"-" json:"items"`
|
||||
}
|
||||
|
||||
// GetListByID returns a list by its ID
|
||||
func GetListByID(id int64) (list List, err error) {
|
||||
func GetListByID(id int64) (list *List, err error) {
|
||||
list.ID = id
|
||||
exists, err := x.Get(&list)
|
||||
if err != nil {
|
||||
return List{}, err
|
||||
return &List{}, err
|
||||
}
|
||||
|
||||
if !exists {
|
||||
return List{}, ErrListDoesNotExist{ID: id}
|
||||
return &List{}, ErrListDoesNotExist{ID: id}
|
||||
}
|
||||
|
||||
// Get the list owner
|
||||
user, _, err := GetUserByID(list.OwnerID)
|
||||
if err != nil {
|
||||
return List{}, err
|
||||
return &List{}, err
|
||||
}
|
||||
|
||||
list.Owner = user
|
||||
@ -61,3 +62,12 @@ func GetListsByUser(user *User) (lists []*List, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GetListsByNamespaceID(nID int64) (lists []*List, err error) {
|
||||
exists, err := x.Where("namespace_id = ?", nID).Get(lists)
|
||||
if !exists {
|
||||
return lists, ErrNamespaceDoesNotExist{}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user