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
commit4c8aa9d4dc641b6c9c2bbce7b35f0373f12c2e51 (patch)
tree57c3785f89ccc4a67c26dc44f26a0880f3f421e7
parent9eb08d29098fa558a0fa2a4d6236d2dfba207b81 (diff)
downloadIshtar-4c8aa9d4dc641b6c9c2bbce7b35f0373f12c2e51.tar.bz2
Ishtar-4c8aa9d4dc641b6c9c2bbce7b35f0373f12c2e51.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()