|
|
@ -63,26 +63,28 @@ class NodesRelationMixin:
|
|
|
|
nodes = Node.objects.filter(id=Node.org_root().id)
|
|
|
|
nodes = Node.objects.filter(id=Node.org_root().id)
|
|
|
|
return nodes
|
|
|
|
return nodes
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_nodes(self, flat=False, only_keys=False):
|
|
|
|
def get_all_nodes(self, flat=False):
|
|
|
|
from ..node import Node
|
|
|
|
from ..node import Node
|
|
|
|
node_keys = set()
|
|
|
|
node_keys = self.get_all_node_keys()
|
|
|
|
for node in self.get_nodes():
|
|
|
|
|
|
|
|
ancestor_keys = node.get_ancestor_keys(with_self=True)
|
|
|
|
|
|
|
|
node_keys.update(ancestor_keys)
|
|
|
|
|
|
|
|
if only_keys:
|
|
|
|
|
|
|
|
return node_keys
|
|
|
|
|
|
|
|
nodes = Node.objects.filter(key__in=node_keys).distinct()
|
|
|
|
nodes = Node.objects.filter(key__in=node_keys).distinct()
|
|
|
|
if not flat:
|
|
|
|
if not flat:
|
|
|
|
return nodes
|
|
|
|
return nodes
|
|
|
|
node_ids = set(nodes.values_list('id', flat=True))
|
|
|
|
node_ids = set(nodes.values_list('id', flat=True))
|
|
|
|
return node_ids
|
|
|
|
return node_ids
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_node_keys(self):
|
|
|
|
|
|
|
|
node_keys = set()
|
|
|
|
|
|
|
|
for node in self.get_nodes():
|
|
|
|
|
|
|
|
ancestor_keys = node.get_ancestor_keys(with_self=True)
|
|
|
|
|
|
|
|
node_keys.update(ancestor_keys)
|
|
|
|
|
|
|
|
return node_keys
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def get_all_nodes_for_assets(cls, assets):
|
|
|
|
def get_all_nodes_for_assets(cls, assets):
|
|
|
|
from ..node import Node
|
|
|
|
from ..node import Node
|
|
|
|
node_keys = set()
|
|
|
|
node_keys = set()
|
|
|
|
for asset in assets:
|
|
|
|
for asset in assets:
|
|
|
|
asset_node_keys = asset.get_all_nodes(only_keys=True)
|
|
|
|
asset_node_keys = asset.get_all_node_keys()
|
|
|
|
node_keys.update(asset_node_keys)
|
|
|
|
node_keys.update(asset_node_keys)
|
|
|
|
nodes = Node.objects.filter(key__in=node_keys)
|
|
|
|
nodes = Node.objects.filter(key__in=node_keys)
|
|
|
|
return nodes
|
|
|
|
return nodes
|
|
|
|