From 3e162780236ca6608270665b0cbc9c75c27a2a75 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 19 Aug 2016 13:09:51 +0200 Subject: Person sheet: improve display of documents (refs #2944) --- ishtar_common/models.py | 15 ++++++++++ ishtar_common/templates/ishtar/sheet_person.html | 35 ++++++++++-------------- 2 files changed, 29 insertions(+), 21 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 97e578f01..6438a1f2c 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2336,6 +2336,21 @@ class Person(Address, Merge, OwnPerms, ValueGetter): if getattr(self, attr)] return slugify(u"-".join(values)) + def operation_docs_q(self): + from archaeological_operations.models import OperationSource + return OperationSource.objects.filter( + authors__person=self) + + def contextrecord_docs_q(self): + from archaeological_context_records.models import ContextRecordSource + return ContextRecordSource.objects.filter( + authors__person=self) + + def find_docs_q(self): + from archaeological_finds.models import FindSource + return FindSource.objects.filter( + authors__person=self) + def save(self, *args, **kwargs): super(Person, self).save(*args, **kwargs) if hasattr(self, 'responsible_town_planning_service'): diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html index 90b65b72c..3c554acdf 100644 --- a/ishtar_common/templates/ishtar/sheet_person.html +++ b/ishtar_common/templates/ishtar/sheet_person.html @@ -83,27 +83,20 @@ {% dynamic_table_document af 'files' 'in_charge' item.pk '' output %} {% endif %} - - - - - - - - - {% for author in item.author.all %} - {% for doc in author.related_sources %} - - - - - - - {% endfor %} - {% empty %} - - {% endfor %} -
{%trans "Documents"%}
{% trans "Year" %}{% trans "Title" %}{% trans "Type" %}{% trans "Link" %}
{{ doc.creation_date|date:"Y"}}{{ doc.title }}{{ doc.source_type }}{% if doc.associated_url %}{% trans "Link"%}{% endif %}
{% trans "No document associated to this person" %}
+{% if item.operation_docs_q.count %} +{% trans "Documents associated to operations" as operation_docs %} +{% dynamic_table_document operation_docs 'operation_docs' 'person' item.pk '' output %} +{% endif %} + +{% if item.contextrecord_docs_q.count %} +{% trans "Documents associated to context records" as context_records %} +{% dynamic_table_document context_records 'context_records_docs' 'person' item.pk '' output %} +{% endif %} + +{% if item.find_docs_q.count %} +{% trans "Documents associated to finds" as finds_docs %} +{% dynamic_table_document finds_docs 'finds_docs' 'person' item.pk '' output %} +{% endif %} {% endblock %} -- cgit v1.2.3