From 0d38c926aa368e4f0401b8d20cc6c05bdabcbc45 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 31 Dec 2020 11:31:20 +0100 Subject: Templates: add finds to containers --- archaeological_warehouse/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'archaeological_warehouse/models.py') diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 80774e31c..06944fa38 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1306,6 +1306,17 @@ class Container(DocumentItem, Merge, LightHistorizedItem, return self.set_static_localisation(8, value) set_static_localisation_9.post_save = True + def get_values(self, prefix='', no_values=False, filtr=None, **kwargs): + values = super(Container, self).get_values( + prefix=prefix, no_values=no_values, filtr=filtr, **kwargs) + + if not filtr or prefix + 'finds' in filtr: + values[prefix + 'finds'] = [ + f.get_values( + prefix=prefix, no_values=True, filtr=None, **kwargs) + for f in self.finds.distinct().all()] + return values + def get_extra_actions(self, request): """ extra actions for the sheet template -- cgit v1.2.3