From 9aa59d8ea96e19d472227ff6eefdefc929523700 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 21 Jan 2018 19:46:01 +0100 Subject: Treatment file: adapt forms, models and sheet --- archaeological_finds/forms_treatments.py | 4 +- archaeological_finds/models_treatments.py | 9 +++ .../templates/ishtar/sheet_treatmentfile.html | 74 +++++++++++++--------- 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index 56eb76802..fd74cc599 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -285,8 +285,8 @@ class TreatmentDeletionForm(FinalForm): u"lost!") confirm_end_msg = _(u"Would you like to delete this treatment?") -SLICING = (("month", _(u"months")), ('year', _(u"years")),) +SLICING = (("month", _(u"months")), ('year', _(u"years")),) DATE_SOURCE = (("start", _(u"Start date")), ("end", _(u"Closing date")),) @@ -402,6 +402,7 @@ class AdministrativeActTreatmentModifForm( class TreatmentFileSelect(TableSelect): + search_vector = forms.CharField(label=_(u"Full text search")) name = forms.CharField(label=_(u"Name")) internal_reference = forms.CharField(label=_(u"Internal ref.")) year = forms.IntegerField(label=_(u"Year")) @@ -433,6 +434,7 @@ class TreatmentFileSelect(TableSelect): class TreatmentFileFormSelection(forms.Form): + SEARCH_AND_SELECT = True form_label = _("Treatment request search") associated_models = {'pk': models.TreatmentFile} currents = {'pk': models.TreatmentFile} diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index a09df554e..b35912fd0 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -286,6 +286,7 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, return "-".join([str(slugify(getattr(self, attr))) for attr in ('year', 'index', 'label')]) + post_save.connect(cached_label_changed, sender=Treatment) @@ -302,6 +303,7 @@ def pre_delete_treatment(sender, **kwargs): find.downstream_treatment = None find.save() + pre_delete.connect(pre_delete_treatment, sender=Treatment) @@ -479,6 +481,8 @@ class TreatmentFileType(GeneralType): verbose_name = _(u"Treatment request type") verbose_name_plural = _(u"Treatment request types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=TreatmentFileType) post_delete.connect(post_save_cache, sender=TreatmentFileType) @@ -488,6 +492,11 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem, SLUG = 'treatmentfile' SHOW_URL = 'show-treatmentfile' TABLE_COLS = ['type', 'year', 'index', 'internal_reference', 'name'] + BASE_SEARCH_VECTORS = [ + 'type__label', 'internal_reference', 'name', 'comment' + ] + INT_SEARCH_VECTORS = ['year', 'index'] + PARENT_SEARCH_VECTORS = ['in_charge', 'applicant', 'applicant_organisation'] SLUG = 'treatmentfile' # fields diff --git a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html index 9567d3081..f474aab7c 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html +++ b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html @@ -1,46 +1,60 @@ {% 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 request" %}{% endblock %} -{% block content %} +{% block head_title %}{% trans "Treatment request" %} - {{ item.name|default:"" }}{% endblock %} + +{% block toolbar %} {% window_nav item window_id 'show-treatmentfile' 'treatmentfile_modify' 'show-historized-treatmentfile' 'revert-treatmentfile' previous next 1 %} +{% endblock %} -

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

-{% if item.internal_reference %} -

{{ item.internal_reference }}

{% endif %} -

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

-{% if item.external_id %} -

{{ item.external_id }}

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

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

-{% else %} -

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

-{% endif %} +{% block content %} - -{% field "Comment" item.comment "
" "
" %} +
+
+
+
+

+

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

+ {% if item.internal_reference %} +

{{ item.internal_reference }}

{% endif %} +

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

+ {% if item.external_id %} +

{{ item.external_id }}

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

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

+ {% else %} +

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

+ {% endif %} +

+
+
+
+
-{% include "ishtar/blocks/sheet_json.html" %} +
+ {% field_flex "Type" item.type %} + {% field_flex_detail "Responsible" item.in_charge %} + {% field_flex "Creation date" item.creation_date %} + {% field_flex "Reception date" item.reception_date %} + {% field_flex "Closing date" item.end_date %} + {% field_flex_full "Comment" item.comment "
" "
" %} + {% include "ishtar/blocks/sheet_json.html" %} +
{% if item.applicant %}

{% trans "Applicant" %}

- -{% field "Contact" item.applicant.address_lbl %} +
+ {% field_flex_detail "Name" item.applicant %} + {% field_flex_full "Contact" item.applicant.address_lbl %} +
{% endif %} + {% if item.applicant_organisation %}

{% trans "Applicant organisation" %}

- -{% field "Contact" item.applicant.address_lbl %} +
+ {% field_flex_detail "Name" item.applicant_organisation %} + {% field_flex_full "Contact" item.applicant.address_lbl %} +
{% endif %} {% if item.treatments.count %} -- cgit v1.2.3