summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-11-18 16:55:51 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-11-28 11:40:17 +0100
commit804f6a147f0a9d4ccf490e5c3604f0fdf765cd47 (patch)
tree57c3785f89ccc4a67c26dc44f26a0880f3f421e7
parent74345b5d847f5575e52828d998c73a1bc947c934 (diff)
downloadIshtar-804f6a147f0a9d4ccf490e5c3604f0fdf765cd47.tar.bz2
Ishtar-804f6a147f0a9d4ccf490e5c3604f0fdf765cd47.zip
treatment n<->1: add documents
-rw-r--r--archaeological_finds/models_treatments.py8
1 files changed, 8 insertions, 0 deletions
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()