From 804f6a147f0a9d4ccf490e5c3604f0fdf765cd47 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 18 Nov 2018 16:55:51 +0100 Subject: treatment n<->1: add documents --- archaeological_finds/models_treatments.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 4e2eb0faf..c7b888c0d 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -317,6 +317,7 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, "quality", "precise_dating"] current_datings = [] current_base_finds = [] + current_documents = [] for upstream_item in upstream_items: # datings are not explicitly part of the resulting_find # need to reassociate with no duplicate @@ -343,6 +344,13 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, current_base_finds.append(base_find.pk) new_find.base_finds.add(base_find) + # documents + for document in upstream_item.documents.all(): + if document.pk in current_documents: + continue + current_documents.append(document.pk) + new_find.documents.add(document) + upstream_item.downstream_treatment = self upstream_item.history_modifier = self.history_modifier upstream_item.save() -- cgit v1.2.3