diff options
-rw-r--r-- | archaeological_finds/forms.py | 3 | ||||
-rw-r--r-- | archaeological_finds/models.py | 5 | ||||
-rw-r--r-- | archaeological_finds/templates/ishtar/sheet_find.html | 51 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_field.html | 3 | ||||
-rw-r--r-- | ishtar_common/templatetags/window_field.py | 8 | ||||
-rw-r--r-- | ishtar_common/templatetags/window_tables.py | 8 | ||||
-rw-r--r-- | ishtar_common/views.py | 4 |
7 files changed, 50 insertions, 32 deletions
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 @@ <a href='{{item.image.url}}' rel="prettyPhoto" title="{{item.label}}"><img src='{{item.thumbnail.url}}'/></a> {% endif%} -{% if item.label %}<p><label>{%trans "Name"%}{% trans ":"%}</label> -<span class='value'>{{item.label}}</span></p>{% endif %} -{% if item.description %}<p><label>{%trans "Description"%}{% trans ":"%}</label> -<span class='value'>{{item.description}}</span></p>{% endif%} -<p><label>{%trans "Created by:"%}</label> <span class='value'>{{ item.history_creator.ishtaruser.full_label }}</span></p> -<p><label>{%trans "Material type"%}{% trans ":"%}</label> -<span class='value'>{{item.material_type}}</span></p> -{% if item.dating %}<p><label>{%trans "Dating"%}{% trans ":"%}</label> -<span class='value'>{{item.dating}}</span></p>{% endif %} -{% if item.volume %}<p><label>{%trans "Volume (l)"%}{% trans ":"%}</label> -<span class='value'>{{item.volume}}</span></p>{% endif%} -{% if item.weight %}<p><label>{%trans "Weight"%}{% trans ":"%}</label> -<span class='value'>{{item.weight}} {% if item.weight_unit %}{{item.weight_unit}}{% else %}g{% endif %}</span></p>{% endif%} -{% if item.find_number %}<p><label>{%trans "Find number"%}{% trans ":"%}</label> -<span class='value'>{{item.find_number}}</span></p>{% endif%} - -{% if item.conservatory_state %} -<p><label>{%trans "Conservatory state"%}{% trans ":"%}</label> -<span class='value'>{{item.conservatory_state}}</span></p> -{% endif %} -{% if item.preservation_to_consider %} -<p><label>{%trans "Type of preservation to consider"%}{% trans ":"%}</label> -<span class='value'>{{item.preservation_to_consider}}</span></p> +{% 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 %} +<p> + <label>{% trans "Object types" %}</label> + <span class='value'>{% for object_type in item.object_types.all %} + {% if forloop.counter0 %}, {% endif %}{{ object_type }} + {% endfor %}</span> +</p> {% endif %} {% if item.upstream_treatment %}<p><label>{%trans "Upstream treatment"%}{% trans ":"%}</label> diff --git a/ishtar_common/templates/ishtar/blocks/window_field.html b/ishtar_common/templates/ishtar/blocks/window_field.html new file mode 100644 index 000000000..9b2bc6540 --- /dev/null +++ b/ishtar_common/templates/ishtar/blocks/window_field.html @@ -0,0 +1,3 @@ +{% load i18n %} +{% if data %}<p><label>{% trans caption %}{% trans ":"%}</label> +<span class='value'>{{data}}</span></p>{% endif%} diff --git a/ishtar_common/templatetags/window_field.py b/ishtar_common/templatetags/window_field.py new file mode 100644 index 000000000..90cb5391c --- /dev/null +++ b/ishtar_common/templatetags/window_field.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + + +@register.inclusion_tag('ishtar/blocks/window_field.html') +def field(caption, data): + return {'caption': caption, 'data': data} diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py index 5c19eb6df..5eebf6359 100644 --- a/ishtar_common/templatetags/window_tables.py +++ b/ishtar_common/templatetags/window_tables.py @@ -1,12 +1,8 @@ - from django import template -from django.utils.translation import ugettext as _ -import re register = template.Library() + @register.inclusion_tag('ishtar/blocks/window_tables/documents.html') def table_document(caption, data): - return {'caption':caption, 'data':data} - - + return {'caption': caption, 'data': data} diff --git a/ishtar_common/views.py b/ishtar_common/views.py index c9211c219..4f089d258 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -146,7 +146,9 @@ def get_autocomplete_generic(model, extra={'available': True}): query = query & Q(label__icontains=q) limit = 20 objects = model.objects.filter(query)[:limit] - data = json.dumps([{'id': obj.pk, 'value': unicode(obj)} + get_label = lambda x: x.full_label() if hasattr(x, 'full_label') \ + else unicode(x) + data = json.dumps([{'id': obj.pk, 'value': get_label(obj)} for obj in objects]) return HttpResponse(data, mimetype='text/plain') return func |