summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-09-04 17:03:52 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-09-04 17:03:52 +0200
commit46799d5bca1f1d1f43e88e9d34817ae25221063c (patch)
treea56f84759a60b86ef28c4aca68311fc7fa942e14 /archaeological_finds
parent30303bbc898814a1e54eaba7410bdc9fc9669d60 (diff)
downloadIshtar-46799d5bca1f1d1f43e88e9d34817ae25221063c.tar.bz2
Ishtar-46799d5bca1f1d1f43e88e9d34817ae25221063c.zip
✨ templates: clean and add fields for operations (refs #6435)
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models_finds.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index d3b1934e1..72ce12401 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -714,10 +714,19 @@ class BaseFind(
def get_extra_values(self, prefix="", no_values=False, filtr=None, **kwargs):
values = {}
+ kwargs["force_no_base_finds"] = True
no_find = kwargs.get("no_find", False)
if not filtr or prefix + "complete_id" in filtr:
values[prefix + "complete_id"] = self.complete_id()
- if no_find:
+ exclude = kwargs.get("exclude", [])
+ if (not filtr or prefix + "context_record" in filtr) and \
+ "context_record" not in exclude:
+ exclude.append("context_record")
+ kwargs["exclude"] = exclude
+ values[prefix + "context_record"] = self.context_record.get_values(
+ filtr=filtr, **kwargs
+ )
+ if no_find or "finds" in exclude:
return values
if not filtr or prefix + "finds" in filtr:
kwargs["no_base_finds"] = True
@@ -2750,10 +2759,21 @@ class Find(
] = self.get_material_types_recommendations()
if no_base_finds:
return values
+
# by default attach first basefind data
bf = self.get_first_base_find()
if not bf:
return values
+ if not filtr:
+ filtr = []
+ exclude = kwargs.get("exclude", [])
+ exclude += [
+ e for e in ("finds", "base_find_finds", "find", "base_find_find")
+ if e not in exclude
+ ]
+ kwargs["exclude"] = exclude
+ kwargs["no_find"] = True
+
alt_filtr = [k[len("base_find_"):] for k in filtr if k.startswith("base_find_")]
alt_filtr += filtr
v = bf.get_values(prefix=prefix, no_values=True, filtr=alt_filtr, **kwargs)
@@ -2766,7 +2786,8 @@ class Find(
new_values.update(dict((('base_find_' + k, v) for k, v in v.items())))
new_values.update(values)
values = new_values
- kwargs["no_find"] = True
+
+ # list all base finds if necessary
values[prefix + "base_finds"] = [
base_find.get_values(no_values=True, filtr=filtr, **kwargs)
for base_find in self.base_finds.distinct().order_by("-pk").all()