summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-08-19 13:09:51 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-08-19 13:09:51 +0200
commit3e162780236ca6608270665b0cbc9c75c27a2a75 (patch)
treec4885502aec18a4f3e2a767a0e260c083400f23d /ishtar_common
parent780e15a479e6a59f89297387780178dd13c230ca (diff)
downloadIshtar-3e162780236ca6608270665b0cbc9c75c27a2a75.tar.bz2
Ishtar-3e162780236ca6608270665b0cbc9c75c27a2a75.zip
Person sheet: improve display of documents (refs #2944)
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py15
-rw-r--r--ishtar_common/templates/ishtar/sheet_person.html35
2 files changed, 29 insertions, 21 deletions
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 %}
-<table>
- <caption>{%trans "Documents"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Title" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Link" %}</th>
- </tr>
- {% for author in item.author.all %}
- {% for doc in author.related_sources %}
- <tr>
- <td class='string'>{{ doc.creation_date|date:"Y"}}</td>
- <td class='string'>{{ doc.title }}</td>
- <td class='string'>{{ doc.source_type }}</td>
- <td class='string'>{% if doc.associated_url %}<a href='{{doc.associated_url}}'>{% trans "Link"%}</a>{% endif %}</td>
- </tr>
- {% endfor %}
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No document associated to this person" %}</td></tr>
- {% endfor %}
-</table>
+{% 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 %}