From 2e2d42111a9fae88c174557db206fa08d3d24730 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 9 Mar 2022 12:13:49 +0100 Subject: Templates: optimize template render for containers --- archaeological_finds/models_finds.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'archaeological_finds') diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index c292cd368..933f14237 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1710,6 +1710,8 @@ class Find( "alteration_causes", "cultural_attributions", ] + GET_VALUES_EXTRA = ValueGetter.GET_VALUES_EXTRA + ["complete_id", + "context_record_label"] GET_VALUES_EXTRA_TYPES = ValueGetter.GET_VALUES_EXCLUDE_FIELDS + [ "material_types", "object_types", @@ -2096,6 +2098,24 @@ class Find( lbl += " ({})".format(base) return lbl + @property + def complete_id(self): + """ + Return complete id of associated base find + """ + return " ; ".join( + list(self.base_finds.values_list("cache_complete_id", flat=True)) + ) + + @property + def context_record_label(self): + """ + Return label of associated context records + """ + return " ; ".join( + list(self.base_finds.values_list("context_record__label", flat=True)) + ) + def get_first_base_find(self): if not self.base_finds.count(): return @@ -2106,6 +2126,8 @@ class Find( ("material_types_label", _("Material types string")), ("material_types_code", _("Material types code string")), ("material_types_recommendations", _("Recommendations string from material")), + ("complete_id", _("Complete ID of associated base finds")), + ("context_record_label", _("Label of associated context records")), ] def get_material_types_code(self) -> str: -- cgit v1.2.3