From 8b137576c4695eb8e970e072b5e11b813fdc1e5a Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Fri, 10 Nov 2023 12:34:23 -0500 Subject: [PATCH] Only index on canvas save, not ocr annotation save ref #944 --- apps/iiif/canvases/management/commands/rebuild_ocr.py | 1 + apps/iiif/canvases/tasks.py | 1 + apps/iiif/manifests/documents.py | 5 +---- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/iiif/canvases/management/commands/rebuild_ocr.py b/apps/iiif/canvases/management/commands/rebuild_ocr.py index b345470f4..955b3595e 100644 --- a/apps/iiif/canvases/management/commands/rebuild_ocr.py +++ b/apps/iiif/canvases/management/commands/rebuild_ocr.py @@ -123,4 +123,5 @@ def __rebuild(self, canvas, testing=False): anno.content = word['content'] anno.save() prog_bar.next() + canvas.save() prog_bar.finish() diff --git a/apps/iiif/canvases/tasks.py b/apps/iiif/canvases/tasks.py index af06a2315..78acfdbab 100644 --- a/apps/iiif/canvases/tasks.py +++ b/apps/iiif/canvases/tasks.py @@ -16,6 +16,7 @@ def add_ocr_task(canvas_id, *args, **kwargs): if ocr is not None: add_ocr_annotations(canvas, ocr) + canvas.save() # trigger reindex @app.task(name='adding_oa_ocr_to_canvas', retry_backoff=5) def add_oa_ocr_task(annotation_list_url): diff --git a/apps/iiif/manifests/documents.py b/apps/iiif/manifests/documents.py index a70b1ec0b..4c5100fb3 100644 --- a/apps/iiif/manifests/documents.py +++ b/apps/iiif/manifests/documents.py @@ -67,7 +67,7 @@ class Django: "publisher", "viewingdirection", ] - related_models = [Collection, Canvas, Annotation] + related_models = [Collection, Canvas] def prepare_authors(self, instance): """convert authors string into list""" @@ -125,6 +125,3 @@ def get_instances_from_related(self, related_instance): elif isinstance(related_instance, Canvas): # many to many relationship return related_instance.manifest - elif isinstance(related_instance, Annotation): - # many to many relationship - return related_instance.canvas.manifest