diff options
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 179ed154d..1c0acadbc 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -1225,6 +1225,23 @@ class ContextRecord( def find_docs_q(self): return Document.objects.filter(finds__base_finds__context_record=self) + def get_deleted_data(self) -> dict: + """ + Return sub object list that will be deleted + :return: {"Sub object type": ["Sub object 1", "Sub object 2", ...]} + """ + if not self.base_finds.count(): + return {} + lbl = str(_("Base finds")) + data = {lbl: []} + for item in self.base_finds.all(): + data[lbl].append(str(item)) + for key, value in item.get_deleted_data().items(): + if key not in data: + data[key] = [] + data[key] += value + return data + def fix(self): """ Fix redundant m2m dating association (usually after imports) |