summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-21 19:32:44 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-21 19:32:44 +0100
commite5d2a40188823a7df05a8f7c392e60b98366ff45 (patch)
treedcc1f0469b2bf188368478af4ef1b9164aaf58ee
parent0b8e5be283b27a968829bd06f7bae767bde12ef5 (diff)
downloadIshtar-e5d2a40188823a7df05a8f7c392e60b98366ff45.tar.bz2
Ishtar-e5d2a40188823a7df05a8f7c392e60b98366ff45.zip
Treatment: adapt forms, models and sheet
-rw-r--r--archaeological_finds/forms_treatments.py2
-rw-r--r--archaeological_finds/models_treatments.py9
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment.html85
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 %}<strong>{% trans "Treatment" %}</strong> - {{ 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 %}
-<a href='{{item.image.url}}' rel="prettyPhoto" title="{{item.label}}" class='photo'><img src='{{item.thumbnail.url}}'/></a>
-{% endif%}
+{% block content %}
-<p class="window-refs">{{ item.label|default:"" }}</p>
-{% if item.other_reference %}
-<p class="window-refs">{{ item.other_reference }}</p>{% endif %}
-<p class="window-refs">{{ item.year }} - {{ item.index }}</p>
-{% if item.external_id %}
-<p class="window-refs">{{ item.external_id }}</p>{% endif %}
-{% if item.end_date %}
-<p class="window-refs">{% trans "Closed" context "Treatment" %} ({{item.end_date}})</p>
-{% else %}
-<p class="window-refs">{% trans "Active" context "Treatment" %}</p>
-{% endif %}
+<div class="row">
+ <div class="offset-lg-4 col-lg-4 offset-md-3 col-md-6 offset-sm-1 col-sm-10 col-12">
+ <div class="card">
+ {% if item.image %}
+ <img class='card-img-top' src="{{item.thumbnail.url}}">
+ {% endif%}
+ <div class="card-body">
+ <p class="card-text">
+ <p class="window-refs">{{ item.label|default:"" }}</p>
+ {% if item.other_reference %}
+ <p class="window-refs">{{ item.other_reference }}</p>{% endif %}
+ <p class="window-refs">{{ item.year }} - {{ item.index }}</p>
+ {% if item.external_id %}
+ <p class="window-refs">{{ item.external_id }}</p>{% endif %}
+ {% if item.end_date %}
+ <p class="window-refs">{% trans "Closed" context "Treatment" %} ({{item.end_date}})</p>
+ {% else %}
+ <p class="window-refs">{% trans "Active" context "Treatment" %}</p>
+ {% endif %}
+ </p>
+ </div>
+ </div>
+ </div>
+</div>
-<ul class='form-flex'>
- {% field_li_multiple "Treatment type" item.treatment_types %}
- {% field_li "State" item.treatment_state %}
- {% field_li_detail "Associated request" item.file %}
- {% field_li "Location" item.location %}
- {% field_li "Container" item.container %}
- {% field_li "Responsible" item.person %}
- {% field_li "Organization" item.organization %}
- {% field_li "Start date" item.start_date %}
- {% field_li "Closing date" item.end_date %}
- {% field_li "Estimated cost" item.estimated_cost|intcomma '' " "|add:CURRENCY %}
- {% field_li "Quoted cost" item.quoted_cost|intcomma '' " "|add:CURRENCY %}
- {% field_li "Realized cost" item.realized_cost|intcomma '' " "|add:CURRENCY %}
- {% field_li "Insurance cost" item.insurance_cost|intcomma '' " "|add:CURRENCY %}
-</ul>
-{% if item.description or item.comment or item.goal %}
-{% field "Comment" item.comment "<pre>" "</pre>" %}
-{% field "Description" item.description "<pre>" "</pre>" %}
-{% field "Goal" item.goal "<pre>" "</pre>" %}
-{% endif %}
+<div class="row">
+ {% 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 "<pre>" "</pre>" %}
+ {% field_flex_full "Description" item.description "<pre>" "</pre>" %}
+ {% field_flex_full "Goal" item.goal "<pre>" "</pre>" %}
-{% include "ishtar/blocks/sheet_json.html" %}
+ {% include "ishtar/blocks/sheet_json.html" %}
+</div>
{% trans "Upstream finds" as finds %}
{% if item.upstream.count %}