diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-21 20:28:02 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-21 20:28:02 +0100 |
commit | f4bad8942ed753b85fcf7bdb00ce666bebe53c97 (patch) | |
tree | 5e230e6e9a775029ee560a92a4678064ae1a3ec4 /archaeological_operations | |
parent | af1ea36dabb2cd1e165e54020286ff723c109f37 (diff) | |
download | Ishtar-f4bad8942ed753b85fcf7bdb00ce666bebe53c97.tar.bz2 Ishtar-f4bad8942ed753b85fcf7bdb00ce666bebe53c97.zip |
Administrativ act: adapt forms, models and sheet
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/forms.py | 2 | ||||
-rw-r--r-- | archaeological_operations/models.py | 36 | ||||
-rw-r--r-- | archaeological_operations/templates/ishtar/sheet_administrativeact.html | 51 |
3 files changed, 53 insertions, 36 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index d26af8771..3541020d8 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -1327,6 +1327,7 @@ OperationSourceFormSelection = get_form_selection( class AdministrativeActOpeSelect(TableSelect): + search_vector = forms.CharField(label=_(u"Full text search")) year = forms.IntegerField(label=_("Year")) index = forms.IntegerField(label=_("Index")) if settings.COUNTRY == 'fr': @@ -1380,6 +1381,7 @@ class AdministrativeActOpeSelect(TableSelect): class AdministrativeActOpeFormSelection(IshtarForm): + SEARCH_AND_SELECT = True form_label = _("Administrative act search") associated_models = {'pk': models.AdministrativeAct} currents = {'pk': models.AdministrativeAct} diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 58fa8b8c6..d46d55089 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -986,6 +986,8 @@ class ActType(GeneralType): verbose_name = _(u"Act type") verbose_name_plural = _(u"Act types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=ActType) post_delete.connect(post_save_cache, sender=ActType) @@ -1051,6 +1053,12 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): RELATIVE_SESSION_NAMES = [('operation', 'operation__pk'), ('file', 'associated_file__pk')] COL_LABELS = {'full_ref': _(u"Ref.")} + BASE_SEARCH_VECTORS = ['act_type__label', 'act_object', + 'towns_label'] + INT_SEARCH_VECTORS = ["year", "index"] + PARENT_SEARCH_VECTORS = ['operator', 'scientist', 'signatory', + 'associated_file', 'operation', 'treatment_file', + 'treatment'] # fields act_type = models.ForeignKey(ActType, verbose_name=_(u"Act type")) @@ -1248,25 +1256,23 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): if 'force' in kwargs: force = kwargs.pop('force') - if not self.signature_date: - return super(AdministrativeAct, self).save(*args, **kwargs) - self.year = self.signature_date.year - - if not self.act_type.indexed: - return super(AdministrativeAct, self).save(*args, **kwargs) - - if not force: - self._get_index() - else: - try: - self._get_index() - except: - pass - + if self.signature_date: + self.year = self.signature_date.year + if self.act_type.indexed: + if not force: + self._get_index() + else: + try: + self._get_index() + except: + pass super(AdministrativeAct, self).save(*args, **kwargs) if hasattr(self, 'associated_file') and self.associated_file: self.associated_file.update_has_admin_act() self.associated_file.update_short_menu_class() + updated = self.update_search_vector() + if updated: + self.save() def strip_zero(value): diff --git a/archaeological_operations/templates/ishtar/sheet_administrativeact.html b/archaeological_operations/templates/ishtar/sheet_administrativeact.html index 92246ba80..1ea2a789d 100644 --- a/archaeological_operations/templates/ishtar/sheet_administrativeact.html +++ b/archaeological_operations/templates/ishtar/sheet_administrativeact.html @@ -1,9 +1,9 @@ {% extends "ishtar/sheet.html" %} {% load i18n window_header window_field %} -{% block head_title %}{% trans "Administrative act" %}{% endblock %} +{% block head_title %}<strong>{% trans "Administrative act" %}</strong> - {{item.full_ref}}{% endblock %} -{% block content %} +{% block toolbar %} {% if item.operation %} {% window_nav item window_id 'show-administrativeact' 'operation_administrativeactop_modify' %} {% endif %} @@ -16,31 +16,40 @@ {% if item.treatment_file %} {% window_nav item window_id 'show-administrativeact' 'treatmentfile_administrativeacttreatmentfile_modify' %} {% endif %} +{% endblock %} + +{% block content %} <h3>{% trans "General"%}</h3> -<ul class='form-flex'> - {% field_li "Year" item.year %} - {% field_li "Index" item.index %} - {% field_li "Internal reference" item.ref_sra %} - {% field_li "Type" item.act_type %} - {% field_li "Object" item.act_object %} - {% field_li "Signature date" item.signature_date %} - {% field_li "In charge" item.in_charge %} - {% field_li "Archaeological preventive operator" item.operator %} - {% field_li_detail "Associated file" item.associated_file %} - {% field_li_detail "Operation" item.operation %} - {% field_li_detail "Treatment" item.treatment %} - {% field_li_detail "Treatment request" item.treatment_file %} +<div class="row"> + {% field_flex "Year" item.year %} + {% field_flex "Index" item.index %} + {% field_flex "Internal reference" item.ref_sra %} + {% field_flex "Type" item.act_type %} + {% field_flex "Object" item.act_object %} + {% field_flex "Signature date" item.signature_date %} + {% field_flex "In charge" item.in_charge %} + {% field_flex "Archaeological preventive operator" item.operator %} + {% field_flex_detail "Associated file" item.associated_file %} + {% field_flex_detail "Operation" item.operation %} + {% field_flex_detail "Treatment" item.treatment %} + {% field_flex_detail "Treatment request" item.treatment_file %} {% if item.operation and item.operation.surface %} - <li><label>{% trans "Surface"%}</label> <span class='value'>{{ item.operation.surface }} m<sup>2</sup> ({{ item.operation.surface_ha }} ha)</span></li> + <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> + <dt class="col-5">{% trans "Surface"%}</dt> + <dd class='col-7'> + {{ item.operation.surface }} m<sup>2</sup> ({{ item.operation.surface_ha }} ha) + </dd> + </div> {% endif %} - {% field_li_detail "Created by" item.history_creator.ishtaruser.person %} -{% comment %}{% if item.general_contractor.attached_to %}<p> + {% field_flex_detail "Created by" item.history_creator.ishtaruser.person %} + + {% comment %}{% if item.general_contractor.attached_to %}<p> <label>{% trans "General contractor organisation"%}</label> <span class='value'>{{ item.general_contractor.attached_to }}</span></p>{% endif %} <!-- Contractor's organisation displayed as concat of Name/Adress/postal_code/city --> -{% if item.general_contractor %}<p><label>{%trans "General contractor"%}</label> <span class='value'>{{ item.general_contractor.full_label }}</span></p>{% endif %} -{% endcomment %} -</ul> + {% if item.general_contractor %}<p><label>{%trans "General contractor"%}</label> <span class='value'>{{ item.general_contractor.full_label }}</span></p>{% endif %} + {% endcomment %} +</div> {% endblock %} |