Fix getting lists for shared, favorite and saved lists namespace
This commit is contained in:
parent
fc4eb8ceb9
commit
6fa95e6492
3 changed files with 44 additions and 15 deletions
|
@ -102,20 +102,42 @@ var FavoritesPseudoList = List{
|
||||||
|
|
||||||
// GetListsByNamespaceID gets all lists in a namespace
|
// GetListsByNamespaceID gets all lists in a namespace
|
||||||
func GetListsByNamespaceID(s *xorm.Session, nID int64, doer *user.User) (lists []*List, err error) {
|
func GetListsByNamespaceID(s *xorm.Session, nID int64, doer *user.User) (lists []*List, err error) {
|
||||||
if nID == -1 {
|
switch nID {
|
||||||
err = s.Select("l.*").
|
case SharedListsPseudoNamespace.ID:
|
||||||
Table("list").
|
nnn, err := getSharedListsInNamespace(s, false, doer)
|
||||||
Join("LEFT", []string{"team_list", "tl"}, "l.id = tl.list_id").
|
if err != nil {
|
||||||
Join("LEFT", []string{"team_members", "tm"}, "tm.team_id = tl.team_id").
|
return nil, err
|
||||||
Join("LEFT", []string{"users_list", "ul"}, "ul.list_id = l.id").
|
}
|
||||||
Join("LEFT", []string{"namespaces", "n"}, "l.namespace_id = n.id").
|
if nnn != nil && nnn.Lists != nil {
|
||||||
Where("tm.user_id = ?", doer.ID).
|
lists = nnn.Lists
|
||||||
Where("l.is_archived = false").
|
}
|
||||||
Where("n.is_archived = false").
|
case FavoritesPseudoNamespace.ID:
|
||||||
Or("ul.user_id = ?", doer.ID).
|
namespaces := make(map[int64]*NamespaceWithLists)
|
||||||
GroupBy("l.id").
|
_, err := getNamespacesWithLists(s, &namespaces, "", false, 0, -1, doer.ID)
|
||||||
Find(&lists)
|
if err != nil {
|
||||||
} else {
|
return nil, err
|
||||||
|
}
|
||||||
|
namespaceIDs, _ := getNamespaceOwnerIDs(namespaces)
|
||||||
|
ls, err := getListsForNamespaces(s, namespaceIDs, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nnn, err := getFavoriteLists(s, ls, namespaceIDs, doer)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if nnn != nil && nnn.Lists != nil {
|
||||||
|
lists = nnn.Lists
|
||||||
|
}
|
||||||
|
case SavedFiltersPseudoNamespace.ID:
|
||||||
|
nnn, err := getSavedFilters(s, doer)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if nnn != nil && nnn.Lists != nil {
|
||||||
|
lists = nnn.Lists
|
||||||
|
}
|
||||||
|
default:
|
||||||
err = s.Select("l.*").
|
err = s.Select("l.*").
|
||||||
Alias("l").
|
Alias("l").
|
||||||
Join("LEFT", []string{"namespaces", "n"}, "l.namespace_id = n.id").
|
Join("LEFT", []string{"namespaces", "n"}, "l.namespace_id = n.id").
|
||||||
|
|
|
@ -113,6 +113,10 @@ func getNamespaceSimpleByID(s *xorm.Session, id int64) (namespace *Namespace, er
|
||||||
return &FavoritesPseudoNamespace, nil
|
return &FavoritesPseudoNamespace, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if id == SavedFiltersPseudoNamespace.ID {
|
||||||
|
return &SavedFiltersPseudoNamespace, nil
|
||||||
|
}
|
||||||
|
|
||||||
namespace = &Namespace{}
|
namespace = &Namespace{}
|
||||||
|
|
||||||
exists, err := s.Where("id = ?", id).Get(namespace)
|
exists, err := s.Where("id = ?", id).Get(namespace)
|
||||||
|
|
|
@ -72,7 +72,10 @@ func (n *Namespace) checkRight(s *xorm.Session, a web.Auth, rights ...Right) (bo
|
||||||
return false, 0, err
|
return false, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.GetID() == nn.OwnerID {
|
if a.GetID() == nn.OwnerID ||
|
||||||
|
nn.ID == SharedListsPseudoNamespace.ID ||
|
||||||
|
nn.ID == FavoritesPseudoNamespace.ID ||
|
||||||
|
nn.ID == SavedFiltersPseudoNamespace.ID {
|
||||||
return true, int(RightAdmin), nil
|
return true, int(RightAdmin), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue