Esempio n. 1
0
    def handle(self, *args, **options):
        # index nodes
        root_nodes = Node.get_collection_roots()
        for root in root_nodes:
            self.index_collection(root)

        # index media items
        media_entries = Media.objects.select_related('collection',
                                                     'set').iterator()
        for media in media_entries:
            if media.pk not in self.media_pks:
                self.index_media(media)

        self.index_items()
Esempio n. 2
0
 def index_collection(self, root_node):
     assert root_node in Node.get_collection_roots(
     ), 'Not a collection root node.'
     collection = root_node.collection
     type = ItemType.folder
     for node in root_node.get_descendants().iterator():
         ancestors = node.get_ancestors().values_list('pk', flat=True)
         item = SearchIndexItem(
             id=f'{type}_{node.pk}',
             type=type,
             pk=node.pk,
             title=node.name,
             body=node.description,
             last_update=time.time(),
             parents=list(ancestors),
             collection=collection.slug,
         )
         self.items.append(item)
Esempio n. 3
0
 def get_childrenDirs(self, _):
     return BaseHAVNodeSerializer(
         Node.get_collection_roots(), many=True, context=self.context
     ).data