From 4f88d76377141c04ec4fa467b0bd207cc9e939df Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 21 Jan 2018 18:36:38 +0100 Subject: Adapt container and warehous sheets - container forms --- archaeological_warehouse/forms.py | 4 ++ archaeological_warehouse/models.py | 6 ++ .../templates/ishtar/sheet_container.html | 48 ++++++++----- .../templates/ishtar/sheet_warehouse.html | 84 ++++++++++++---------- 4 files changed, 86 insertions(+), 56 deletions(-) diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 973da2014..5ace42a0e 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -78,6 +78,7 @@ SelectedDivisionFormset.form_slug = "warehouse-020-divisions" class WarehouseSelect(TableSelect): + search_vector = forms.CharField(label=_(u"Full text search")) name = forms.CharField(label=_(u"Name")) warehouse_type = forms.ChoiceField(label=_(u"Warehouse type"), choices=[]) towns = forms.CharField(label=_(u"Town")) @@ -91,6 +92,7 @@ class WarehouseSelect(TableSelect): class WarehouseFormSelection(forms.Form): + SEARCH_AND_SELECT = True form_label = _("Warehouse search") associated_models = {'pk': models.Warehouse} currents = {'pk': models.Warehouse} @@ -243,6 +245,7 @@ class ContainerModifyForm(ContainerForm): class ContainerSelect(TableSelect): + search_vector = forms.CharField(label=_(u"Full text search")) location = get_warehouse_field() container_type = forms.ChoiceField(label=_(u"Container type"), choices=[]) reference = forms.CharField(label=_(u"Ref.")) @@ -254,6 +257,7 @@ class ContainerSelect(TableSelect): self.fields['container_type'].help_text = \ models.ContainerType.get_help() + ContainerFormSelection = get_form_selection( 'ContainerFormSelection', _(u"Container search"), 'container', models.Container, ContainerSelect, 'get-container', diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index d6c33583f..1aad71111 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -63,6 +63,8 @@ class Warehouse(Address, DashboardFormItem, OwnPerms): _(u"External ID is set automatically"), default=False) TABLE_COLS = ['name', 'warehouse_type'] + BASE_SEARCH_VECTORS = ['name', 'warehouse_type__label', "external_id", + "town", "comment"] class Meta: verbose_name = _(u"Warehouse") @@ -261,6 +263,10 @@ class Container(LightHistorizedItem, ImageModel): TABLE_COLS = ['reference', 'container_type__label', 'cached_location', 'divisions_lbl'] IMAGE_PREFIX = 'containers/' + BASE_SEARCH_VECTORS = ['reference', 'container_type__label', + 'cached_location'] + M2M_SEARCH_VECTORS = ['division__reference', + 'division__division__division__label'] # search parameters EXTRA_REQUEST_KEYS = { diff --git a/archaeological_warehouse/templates/ishtar/sheet_container.html b/archaeological_warehouse/templates/ishtar/sheet_container.html index 7c9f84a32..b1e74fb88 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_container.html +++ b/archaeological_warehouse/templates/ishtar/sheet_container.html @@ -1,29 +1,41 @@ {% extends "ishtar/sheet.html" %} {% load i18n window_header window_field window_tables %} -{% block head_title %}{% trans "Container" %}{% endblock %} +{% block head_title %}{% trans "Container" %} - {{ item.reference|default:"" }} ({{ item.container_type|default:"" }}){% endblock %} -{% block content %} +{% block toolbar %} {% window_nav item window_id 'show-container' 'container_modify' '' '' previous next 1 %} +{% endblock %} -{% if item.image %} - -{% endif%} - -

{{ item.reference|default:"" }}

-

{{ item.container_type|default:"" }}

-

{{ item.responsible.name }} - {{ item.index }}

-{% include "ishtar/blocks/sheet_external_id.html" %} - - -{% field "Location" item.precise_location %} -{% field "Comment" item.comment "
" "
" %} + {% field_flex "Location" item.precise_location %} + {% field_flex_full "Comment" item.comment "
" "
" %} + {% include "ishtar/blocks/sheet_json.html" %} + -{% include "ishtar/blocks/sheet_json.html" %} {% if item.finds.count %}

{% trans "Content" %}

diff --git a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html index de93f9af3..03a8eec5c 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html +++ b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html @@ -1,23 +1,39 @@ {% extends "ishtar/sheet.html" %} {% load i18n window_header window_field window_tables %} -{% block head_title %}{% trans "Warehouse" %}{% endblock %} +{% block head_title %}{% trans "Warehouse" %} - {{item.name}} ({{item.warehouse_type}}){% endblock %} +{% block toolbar %} +{% window_nav item window_id 'show-warehouse' 'warehouse_modify' '' '' previous next 1 %} +{% endblock %} {% block content %} -{% window_nav item window_id 'show-warehouse' 'warehouse_modify' '' '' previous next 1 %} -

{{ item.name|default:"" }}

-

{{ item.warehouse_type|default:"" }}

-{% include "ishtar/blocks/sheet_external_id.html" %} +
+
+
+ {% if item.image %} + + {% endif%} +
+

+

{{ item.name|default:"" }}

+

{{ item.warehouse_type|default:"" }}

+ {% include "ishtar/blocks/sheet_external_id.html" %} +

+
+
+
+
+ - -{% include "ishtar/blocks/sheet_address_section.html" %} -{% field "Comment" item.comment "
" "
" %} + {% include "ishtar/blocks/sheet_address_section.html" %} + {% field_flex_full "Comment" item.comment "
" "
" %} + {% include "ishtar/blocks/sheet_json.html" %} + -{% include "ishtar/blocks/sheet_json.html" %} {% if item.containers.count %}

{% trans "Containers" %}

@@ -33,44 +49,36 @@ {% trans "These numbers are updated hourly" %}

{% trans "Finds" %}

- +
+ {% field_flex_2 "Number of attached finds" item.number_of_finds %} + {% field_flex_2 "Number of hosted finds" item.number_of_finds_hosted %} +
{% if item.number_of_finds_by_place %}

{% trans "Finds by location in the warehouse" %}

-