From 7569568dd7810cec673758a27ad1f725110e0c1d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 9 Sep 2015 22:36:23 +0200 Subject: Archaeological finds: update sheet and search --- archaeological_finds/forms.py | 3 ++ archaeological_finds/models.py | 5 ++- .../templates/ishtar/sheet_find.html | 51 ++++++++++++---------- 3 files changed, 34 insertions(+), 25 deletions(-) (limited to 'archaeological_finds') diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 82c32b2dc..ae91b8383 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -126,6 +126,7 @@ class FindSelect(TableSelect): dating__period = forms.ChoiceField(label=_(u"Period"), choices=[]) # TODO search by warehouse material_type = forms.ChoiceField(label=_(u"Material type"), choices=[]) + object_types = forms.ChoiceField(label=_(u"Object type"), choices=[]) conservatory_state = forms.ChoiceField(label=_(u"Conservatory state"), choices=[]) base_finds__find__description = forms.CharField(label=_(u"Description")) @@ -144,6 +145,8 @@ class FindSelect(TableSelect): models.ConservatoryState.get_types() self.fields['conservatory_state'].help_text = \ models.ConservatoryState.get_help() + self.fields['object_types'].choices = \ + models.ObjectType.get_types() class FindFormSelection(forms.Form): diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 947cd9067..ce56fac27 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -76,7 +76,7 @@ class ObjectType(GeneralType): verbose_name_plural = _(u"Object types") ordering = ('parent__label', 'label',) - def __unicode__(self): + def full_label(self): lbls = [self.label] item = self while item.parent: @@ -84,6 +84,9 @@ class ObjectType(GeneralType): lbls.append(item.label) return u" > ".join(reversed(lbls)) + def __unicode__(self): + return self.label + class BaseFind(BaseHistorizedItem, OwnPerms): label = models.CharField(_(u"ID"), max_length=60) diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index c5bd637a5..3047b7e87 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 %} +{% load i18n window_field %} {% block head_sheet %} {{block.super}} @@ -28,29 +28,32 @@ {% endif%} -{% if item.label %}

-{{item.label}}

{% endif %} -{% if item.description %}

-{{item.description}}

{% endif%} -

{{ item.history_creator.ishtaruser.full_label }}

-

-{{item.material_type}}

-{% if item.dating %}

-{{item.dating}}

{% endif %} -{% if item.volume %}

-{{item.volume}}

{% endif%} -{% if item.weight %}

-{{item.weight}} {% if item.weight_unit %}{{item.weight_unit}}{% else %}g{% endif %}

{% endif%} -{% if item.find_number %}

-{{item.find_number}}

{% endif%} - -{% if item.conservatory_state %} -

-{{item.conservatory_state}}

-{% endif %} -{% if item.preservation_to_consider %} -

-{{item.preservation_to_consider}}

+{% field "Name" item.label %} +{% field "Description" item.description %} +{% field "Created by" item.history_creator.ishtaruser.full_label %} +{% field "Material type" item.material_type %} +{% 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 %} + +{% if item.weight %}{% with item.weight|add:' '|add:item.weight_unit as weight %} +{% field "Weight" weight %} +{% endwith %}{% endif %} + +{% field "Find number" item.find_number %} +{% field "Conservatory state" item.conservatory_state %} +{% field "Type of preservation to consider" item.preservation_to_consider %} + +{% if item.object_types.count %} +

+ + {% for object_type in item.object_types.all %} + {% if forloop.counter0 %}, {% endif %}{{ object_type }} + {% endfor %} +

{% endif %} {% if item.upstream_treatment %}

-- cgit v1.2.3