From b6d3f2dc4a24bb055b73b7c80815685572a83086 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 18 Feb 2019 12:31:41 +0100 Subject: Sheet site: add associated document list --- archaeological_operations/models.py | 6 ++++++ archaeological_operations/templates/ishtar/sheet_site.html | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 2335155ed..b76e4841e 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -326,6 +326,12 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, def short_class_name(self): return _(u"SITE") + @property + def finds(self): + from archaeological_finds.models import Find + return Find.objects.filter( + base_finds__context_record__archaeological_site__pk=self.pk) + @classmethod def get_query_owns(cls, ishtaruser): from archaeological_warehouse.models import Warehouse diff --git a/archaeological_operations/templates/ishtar/sheet_site.html b/archaeological_operations/templates/ishtar/sheet_site.html index a293cb10b..7b88ff630 100644 --- a/archaeological_operations/templates/ishtar/sheet_site.html +++ b/archaeological_operations/templates/ishtar/sheet_site.html @@ -81,7 +81,16 @@ {% dynamic_table_document operations 'operations' 'archaeological_sites' item.pk '' output %} {% endif %} +{% if item.finds.count %} {% trans "Finds" as finds %} {% dynamic_table_document finds 'finds' 'base_finds__context_record__archaeological_site' item.pk '' output %} +{% endif %} + +{% trans "Documents" as docs %} +{% if permission_view_own_document or permission_view_document %} +{% if item.documents.count %} +{% dynamic_table_document docs 'documents' 'sites' item.pk '' output %} +{% endif %} +{% endif %} {% endblock %} -- cgit v1.2.3