summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-06 17:11:33 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-06 17:11:33 +0200
commit07940735df99aff66b6646fbde7975da26749048 (patch)
tree8a5b3794b713c6f740e0a1e0014469ada3688fcb /archaeological_finds
parent6dfabea03aa0c92206c77d99a07c775e80f787e8 (diff)
downloadIshtar-07940735df99aff66b6646fbde7975da26749048.tar.bz2
Ishtar-07940735df99aff66b6646fbde7975da26749048.zip
Show treatments in find sheet
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models.py40
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html98
2 files changed, 107 insertions, 31 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index 0a1e59a68..b84b7614f 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -304,10 +304,10 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
find_number = models.IntegerField(_("Find number"), blank=True, null=True)
upstream_treatment = models.ForeignKey(
"Treatment", blank=True, null=True,
- related_name='downstream_treatment',
+ related_name='downstream',
verbose_name=_("Upstream treatment"))
downstream_treatment = models.ForeignKey(
- "Treatment", blank=True, null=True, related_name='upstream_treatment',
+ "Treatment", blank=True, null=True, related_name='upstream',
verbose_name=_("Downstream treatment"))
datings = models.ManyToManyField(Dating, verbose_name=_(u"Dating"),
related_name='find')
@@ -413,6 +413,42 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
bf.context_record.operation.get_reference(),
self.index)
+ def upstream_treatments(self):
+ treatments = []
+ base_finds = [bf.pk for bf in self.base_finds.all()]
+ if self.upstream_treatment and \
+ self.upstream_treatment.pk not in treatments:
+ treatments.append((self.upstream_treatment.upstream.distinct(
+ ).order_by('label').all(), self.upstream_treatment))
+ for upstream in self.upstream_treatment.upstream.all():
+ if upstream.pk != self.pk and not [
+ bf.pk for bf in upstream.base_finds.all()
+ if bf.pk in base_finds]:
+ continue
+ for items, treatment in upstream.upstream_treatments():
+ if treatment.pk not in treatments:
+ treatments.append((treatment.upstream.order_by(
+ 'label').all(), treatment))
+ return treatments
+
+ def downstream_treatments(self):
+ treatments = []
+ base_finds = [bf.pk for bf in self.base_finds.all()]
+ if self.downstream_treatment and \
+ self.downstream_treatment.pk not in treatments:
+ treatments.append((self.downstream_treatment.downstream.distinct(
+ ).order_by('label').all(), self.downstream_treatment))
+ for downstream in self.downstream_treatment.downstream.all():
+ if downstream.pk != self.pk and not [
+ bf.pk for bf in downstream.base_finds.all()
+ if bf.pk in base_finds]:
+ continue
+ for items, treatment in downstream.downstream_treatments():
+ if treatment.pk not in treatments:
+ treatments.append((treatment.downstream.order_by(
+ 'label').all(), treatment))
+ return treatments
+
def get_department(self):
bf = self.get_first_base_find()
if not bf:
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index 429a7da2b..ff3dc55dd 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -1,5 +1,5 @@
{% extends "ishtar/sheet.html" %}
-{% load i18n window_field from_dict %}
+{% load i18n window_field from_dict link_to_window %}
{% block head_sheet %}
{{block.super}}
@@ -28,42 +28,82 @@
<a href='{{item.image.url}}' rel="prettyPhoto" title="{{item.label}}"><img src='{{item.thumbnail.url}}'/></a>
{% endif%}
-{% field "Free-ID" item.label %}
-{% field "Previous ID" item.previous_id %}
-{% field "Description" item.description %}
-{% field "Created by" item.history_creator.ishtaruser.full_label %}
-{% field "Administrative index" item.administrative_index %}
-{% field_multiple "Material types" item.material_types %}
-{% field "Dating" item.dating %}
-{% field "Length (cm)" item.length %}
-{% field "Width (cm)" item.width %}
-{% field "Height (cm)" item.height %}
-{% field "Diameter (cm)" item.diameter %}
-{% field "Volume (l)" item.volume %}
+<ul class='form-flex'>
+{% field_li "Free-ID" item.label %}
+{% field_li "Previous ID" item.previous_id %}
+{% field_li "Description" item.description %}
+{% field_li "Created by" item.history_creator.ishtaruser.full_label %}
+{% field_li "Administrative index" item.administrative_index %}
+{% field_li_multiple "Material types" item.material_types %}
+{% field_li "Dating" item.dating %}
+{% field_li "Length (cm)" item.length %}
+{% field_li "Width (cm)" item.width %}
+{% field_li "Height (cm)" item.height %}
+{% field_li "Diameter (cm)" item.diameter %}
+{% field_li "Volume (l)" item.volume %}
{% if item.weight %}{% with item.weight|add:' '|add:item.weight_unit as weight %}
-{% field "Weight" weight %}
+{% field_li "Weight" weight %}
{% endwith %}{% endif %}
-{% field "Weight" item.weight %}
+{% field_li "Weight" item.weight %}
-{% field "Find number" item.find_number %}
-{% field "Conservatory state" item.conservatory_state %}
-{% field_multiple "Type of preservation to consider" item.preservation_to_considers %}
-{% field_multiple "Object types" item.object_types %}
-{% field_multiple "Integrity" item.integrities %}
+{% field_li "Find number" item.find_number %}
+{% field_li "Conservatory state" item.conservatory_state %}
+{% field_li_multiple "Type of preservation to consider" item.preservation_to_considers %}
+{% field_li_multiple "Object types" item.object_types %}
+{% field_li_multiple "Integrity" item.integrities %}
{% if item.CHECK_DICT %}
-{% field "Checked" item.checked|from_dict:item.CHECK_DICT %}
+{% field_li "Checked" item.checked|from_dict:item.CHECK_DICT %}
{% endif%}
{% if item.history_object and item.history_object.CHECK_DICT %}
-{% field "Checked" item.checked|from_dict:item.history_object.CHECK_DICT %}
+{% field_li "Checked" item.checked|from_dict:item.history_object.CHECK_DICT %}
{% endif%}
+{% field_li "Container" item.container %}
+</ul>
-{% if item.upstream_treatment %}<p><label>{%trans "Upstream treatment"%}{% trans ":"%}</label>
-<span class='value'>{{item.upstream_treatment}} ({% for up in item.upstream_treatment.upstream_treatment.all %}{% if forloop.counter0 %}, {%endif %}{{up}}{% endfor %})</span></p>{% endif%}
-{% if item.downstream_treatment %}<p><label>{%trans "Downstream treatment"%}{% trans ":"%}</label>
-<span class='value'>{{item.downstream_treatment}} ({% for dt in item.downstream_treatment.downstream_treatment.all %}{% if forloop.counter0 %}, {%endif %}{{dt}}{% endfor %})</span></p>{% endif%}
-{% if item.container %}<p><label>{%trans "Container"%}{% trans ":"%}</label>
-<span class='value'>{{item.container}}</span></p>{% endif%}
+{% if item.upstream_treatment %}
+<table class='simple' id='{{window_id}}-upstream'>
+ <caption>{% trans "Upstream treatment" %}</caption>
+ <tr>
+ <th>{% trans "Type" %}</th>
+ <th>{% trans "Related find" %}</th>
+ <th>{% trans "Person" %}</th>
+ <th>{% trans "Start date" %}</th>
+ <th>{% trans "End date" %}</th>
+ </tr>
+ {% for items, treatment in item.upstream_treatments %}
+ <tr>
+ <td class='string'>{{ treatment.treatment_type }}</td>
+ <td class='string'>{% for item in items %}{% if not forloop.first %} ; {% endif %} {{item}} {{ item|link_to_window}}{% endfor %}</td>
+ <td class='string'>{{ treatment.person|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment.start_date|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment.end_date|default_if_none:"" }}</td>
+ </tr>
+ {% endfor %}
+</table>
+{% endif %}
+
+{% if item.downstream_treatment %}
+<table class='simple' id='{{window_id}}-downstream'>
+ <caption>{% trans "Downstream treatment" %}</caption>
+ <tr>
+ <th>{% trans "Type" %}</th>
+ <th>{% trans "Related find" %}</th>
+ <th>{% trans "Person" %}</th>
+ <th>{% trans "Start date" %}</th>
+ <th>{% trans "End date" %}</th>
+ </tr>
+ {% for items, treatment in item.downstream_treatments %}
+ <tr>
+ <td class='string'>{{ treatment.treatment_type }}</td>
+ <td class='string'>{% for item in items %}{% if not forloop.first %} ; {% endif %} {{item}} {{ item|link_to_window}}{% endfor %}</td>
+ <td class='string'>{{ treatment.person|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment.start_date|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment.end_date|default_if_none:"" }}</td>
+ </tr>
+ {% endfor %}
+</table>
+{% endif %}
<h3>{% trans "Associated base finds"%}</h3>
@@ -103,7 +143,7 @@
{% endfor %}
{% if not item.source.count %}
- <p class='alert'>{% trans "No document associated to this find" %}</p>
+ <em>{% trans "No document associated to this find" %}</em>
{% else %}
<table class='simple' id='{{window_id}}-docs'>
<caption>{%trans "Documents"%}</caption>