From 41e60b4856d1efe6df3ebd783447a7071e042ca5 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 21 Jan 2018 19:32:44 +0100 Subject: Treatment: adapt forms, models and sheet --- archaeological_finds/forms_treatments.py | 2 + archaeological_finds/models_treatments.py | 9 +++ .../templates/ishtar/sheet_treatment.html | 85 ++++++++++++---------- 3 files changed, 59 insertions(+), 37 deletions(-) diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index 47826390f..56eb76802 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -49,6 +49,7 @@ logger = logging.getLogger(__name__) class TreatmentSelect(TableSelect): + search_vector = forms.CharField(label=_(u"Full text search")) label = forms.CharField(label=_(u"Label")) other_reference = forms.CharField(label=_(u"Other ref.")) year = forms.IntegerField(label=_(u"Year")) @@ -65,6 +66,7 @@ class TreatmentSelect(TableSelect): class TreatmentFormSelection(forms.Form): + SEARCH_AND_SELECT = True form_label = _("Treatment search") associated_models = {'pk': models.Treatment} currents = {'pk': models.Treatment} diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 38d4f55b3..a09df554e 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -41,6 +41,8 @@ class TreatmentState(GeneralType): verbose_name = _(u"Treatment state type") verbose_name_plural = _(u"Treatment state types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=TreatmentState) post_delete.connect(post_save_cache, sender=TreatmentState) @@ -71,6 +73,13 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, # extra keys than can be passed to save method EXTRA_SAVED_KEYS = ('items', 'user') SLUG = 'treatment' + BASE_SEARCH_VECTORS = [ + 'treatment_types__label', 'treatment_state__label', 'label', 'goal', + 'external_id', 'comment', 'description', 'other_reference', + ] + INT_SEARCH_VECTORS = ["year", "index"] + M2M_SEARCH_VECTORS = ['downstream__cached_label', 'upstream__cached_label'] + PARENT_SEARCH_VECTORS = ['person', 'organization'] label = models.CharField(_(u"Label"), blank=True, null=True, max_length=200) other_reference = models.CharField(_(u"Other ref."), blank=True, null=True, diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html index 94f6e20a7..c1da714c2 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatment.html +++ b/archaeological_finds/templates/ishtar/sheet_treatment.html @@ -1,48 +1,59 @@ {% extends "ishtar/sheet.html" %} {% load i18n window_field from_dict link_to_window window_tables window_ope_tables window_header humanize %} -{% block head_title %}{% trans "Treatment" %}{% endblock %} -{% block content %} +{% block head_title %}{% trans "Treatment" %} - {{ item.label|default:"" }}{% endblock %} + +{% block toolbar %} {% window_nav item window_id 'show-treatment' 'treatment_modify' 'show-historized-treatment' 'revert-treatment' previous next 1 %} +{% endblock %} -{% if item.image %} - -{% endif%} +{% block content %} -

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

-{% if item.other_reference %} -

{{ item.other_reference }}

{% endif %} -

{{ item.year }} - {{ item.index }}

-{% if item.external_id %} -

{{ item.external_id }}

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

{% trans "Closed" context "Treatment" %} ({{item.end_date}})

-{% else %} -

{% trans "Active" context "Treatment" %}

-{% endif %} +
+
+
+ {% if item.image %} + + {% endif%} +
+

+

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

+ {% if item.other_reference %} +

{{ item.other_reference }}

{% endif %} +

{{ item.year }} - {{ item.index }}

+ {% if item.external_id %} +

{{ item.external_id }}

{% endif %} + {% if item.end_date %} +

{% trans "Closed" context "Treatment" %} ({{item.end_date}})

+ {% else %} +

{% trans "Active" context "Treatment" %}

+ {% endif %} +

+
+
+
+
- -{% if item.description or item.comment or item.goal %} -{% field "Comment" item.comment "
" "
" %} -{% field "Description" item.description "
" "
" %} -{% field "Goal" item.goal "
" "
" %} -{% endif %} +
+ {% field_flex_multiple "Treatment type" item.treatment_types %} + {% field_flex "State" item.treatment_state %} + {% field_flex_detail "Associated request" item.file %} + {% field_flex "Location" item.location %} + {% field_flex "Container" item.container %} + {% field_flex "Responsible" item.person %} + {% field_flex "Organization" item.organization %} + {% field_flex "Start date" item.start_date %} + {% field_flex "Closing date" item.end_date %} + {% field_flex "Estimated cost" item.estimated_cost|intcomma '' " "|add:CURRENCY %} + {% field_flex "Quoted cost" item.quoted_cost|intcomma '' " "|add:CURRENCY %} + {% field_flex "Realized cost" item.realized_cost|intcomma '' " "|add:CURRENCY %} + {% field_flex "Insurance cost" item.insurance_cost|intcomma '' " "|add:CURRENCY %} + {% field_flex_full "Comment" item.comment "
" "
" %} + {% field_flex_full "Description" item.description "
" "
" %} + {% field_flex_full "Goal" item.goal "
" "
" %} -{% include "ishtar/blocks/sheet_json.html" %} + {% include "ishtar/blocks/sheet_json.html" %} +
{% trans "Upstream finds" as finds %} {% if item.upstream.count %} -- cgit v1.2.3