summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2013-10-28 19:31:45 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2013-10-28 19:31:45 +0100
commitc10b0bac3f5d5ee61d7789de4db0fbb18dd666d3 (patch)
treee2d718346323d03543af43ec1b32e5d38621866e /archaeological_context_records
parent61da3e56ba96f00a4567f7b12f384eb2afe7c87e (diff)
downloadIshtar-c10b0bac3f5d5ee61d7789de4db0fbb18dd666d3.tar.bz2
Ishtar-c10b0bac3f5d5ee61d7789de4db0fbb18dd666d3.zip
Templates: list all dependant documents
New template tags for displaying table of documents
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/models.py12
-rw-r--r--archaeological_context_records/templates/ishtar/sheet_contextrecord.html26
2 files changed, 18 insertions, 20 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 0a970b8ce..b33b86e8c 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -19,6 +19,7 @@
from django.conf import settings
from django.contrib.gis.db import models
+from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _, ugettext, pgettext
from ishtar_common.models import GeneralType, BaseHistorizedItem, \
@@ -157,6 +158,10 @@ class ContextRecord(BaseHistorizedItem, OwnPerms):
return settings.JOINT.join([unicode(item) for item in [self.parcel,
self.label] if item])
+ @property
+ def show_url(self):
+ return reverse('show-contextrecord', args=[self.pk, ''])
+
def full_label(self):
if not self.operation:
return unicode(self)
@@ -218,6 +223,10 @@ class ContextRecord(BaseHistorizedItem, OwnPerms):
def get_total_number(cls):
return cls.objects.filter(operation__start_date__isnull=False).count()
+ def find_docs_q(self):
+ from archaeological_finds.models import FindSource
+ return FindSource.objects.filter(find__base_finds__context_record=self)
+
class ContextRecordSource(Source):
class Meta:
verbose_name = _(u"Context record documentation")
@@ -225,3 +234,6 @@ class ContextRecordSource(Source):
context_record = models.ForeignKey(ContextRecord,
verbose_name=_(u"Context record"), related_name="source")
+ @property
+ def owner(self):
+ return self.context_record
diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
index 741201daa..4284b7eef 100644
--- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
+++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
@@ -1,5 +1,5 @@
{% extends "ishtar/sheet.html" %}
-{% load i18n %}
+{% load i18n window_tables %}
{% block head_sheet %}
{{block.super}}
@@ -92,25 +92,8 @@
{% else %}<p class='alert'><label>{%trans "No operation linked to this context unit!"%}</label></p>
{% endif %}
-<table>
- <caption>{%trans "Documents"%}</caption>
- <tr>
- <th>{% trans "Title" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Authors" %}</th>
- <th>{% trans "Link" %}</th>
- </tr>
- {% for doc in item.source.all %}
- <tr>
- <td class='string'>{{ doc.title }}</td>
- <td class='string'>{{doc.source_type}}</td>
- <td class='string'>{{ doc.authors.all|join:", " }}</td>
- <td class='string'>{% if doc.associated_url %}<a href='{{doc.associated_url}}'>{% trans "Link"%}</a>{% endif %}</td>
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No document associated to this context record" %}</td></tr>
- {% endfor %}
-</table>
+{% trans "Document from this context record" as cr_docs %}
+{% if item.source.count %} {% table_document cr_docs item.source.all %}{% endif %}
<table>
<caption>{%trans "Finds"%}</caption>
@@ -151,4 +134,7 @@
{% endfor %}
</table>
+{% trans "Documents from associated finds" as find_docs %}
+{% if item.find_docs_q.count %} {% table_document find_docs item.find_docs_q.all %}{% endif %}
+
{% endblock %}