From 44c791ce34c48dd8df381a41218d12d563e015ff Mon Sep 17 00:00:00 2001
From: Valentin Rigal <rigal@teklia.com>
Date: Fri, 15 Oct 2021 11:46:02 +0200
Subject: [PATCH] Return the response payload in creation helpers

---
 arkindex_worker/worker/classification.py | 4 ++++
 arkindex_worker/worker/entity.py         | 3 ++-
 arkindex_worker/worker/transcription.py  | 4 ++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arkindex_worker/worker/classification.py b/arkindex_worker/worker/classification.py
index 6d356c39..9e5d95c7 100644
--- a/arkindex_worker/worker/classification.py
+++ b/arkindex_worker/worker/classification.py
@@ -132,6 +132,8 @@ class ClassificationMixin(object):
 
         self.report.add_classification(element.id, ml_class)
 
+        return created
+
     def create_classifications(self, element, classifications):
         """
         Create multiple classifications at once on the given element through the API
@@ -199,3 +201,5 @@ class ClassificationMixin(object):
                 logger.warning(
                     f"Couldn't save created classifications in local cache: {e}"
                 )
+
+        return created_cls
diff --git a/arkindex_worker/worker/entity.py b/arkindex_worker/worker/entity.py
index 7dd5e85d..1cf56165 100644
--- a/arkindex_worker/worker/entity.py
+++ b/arkindex_worker/worker/entity.py
@@ -104,7 +104,7 @@ class EntityMixin(object):
             )
             return
 
-        self.request(
+        transcription_ent = self.request(
             "CreateTranscriptionEntity",
             id=transcription,
             body={
@@ -130,3 +130,4 @@ class EntityMixin(object):
                 logger.warning(
                     f"Couldn't save created transcription entity in local cache: {e}"
                 )
+        return transcription_ent
diff --git a/arkindex_worker/worker/transcription.py b/arkindex_worker/worker/transcription.py
index d89c1425..388f756c 100644
--- a/arkindex_worker/worker/transcription.py
+++ b/arkindex_worker/worker/transcription.py
@@ -59,6 +59,8 @@ class TranscriptionMixin(object):
                     f"Couldn't save created transcription in local cache: {e}"
                 )
 
+        return created
+
     def create_transcriptions(self, transcriptions):
         """
         Create multiple transcriptions at once on existing elements through the API.
@@ -114,6 +116,8 @@ class TranscriptionMixin(object):
                     f"Couldn't save created transcriptions in local cache: {e}"
                 )
 
+        return created_trs
+
     def create_element_transcriptions(self, element, sub_element_type, transcriptions):
         """
         Create multiple sub elements with their transcriptions on the given element through API
-- 
GitLab