Esempio n. 1
0
def get_tree_queryset_descendants(model, nodes, include_self=False):
    if not nodes:
        return nodes
    filters = []
    for n in nodes:
        lft, rght = n.lft, n.rght
        if include_self:
            lft -= 1
            rght += 1
        filters.append(Q(tree_id=n.tree_id, lft__gt=lft, rght__lt=rght))
    q = reduce(operator.or_, filters)
    return model.objects.filter(q).order_by(*model._meta.ordering)
def get_tree_queryset_descendants(model, nodes, include_self=False):
  if not nodes:
    return nodes
  filters = []
  for n in nodes:
    lft, rght = n.lft, n.rght
    if include_self:
      lft -=1
      rght += 1
    filters.append(Q(tree_id=n.tree_id, lft__gt=lft, rght__lt=rght))
  q = reduce(operator.or_, filters)
  return model.objects.filter(q).order_by(*model._meta.ordering)
def get_tree_queryset_all(model, nodes):
  filters = []
  for node in nodes:
    filters.append(Q(tree_id=node.tree_id))
  q = reduce(operator.or_, filters)
  return model.objects.filter(q).order_by(*model._meta.ordering)
Esempio n. 4
0
def get_tree_queryset_all(model, nodes):
    filters = []
    for node in nodes:
        filters.append(Q(tree_id=node.tree_id))
    q = reduce(operator.or_, filters)
    return model.objects.filter(q).order_by(*model._meta.ordering)