diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-21 21:05:28 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-21 21:05:28 +0100 |
commit | 781d7824ca939d3794d3ab098ea8a2311fc2c643 (patch) | |
tree | 695caca9fafeec457b44d9fcc169315de08f8b7b | |
parent | f4bad8942ed753b85fcf7bdb00ce666bebe53c97 (diff) | |
download | Ishtar-781d7824ca939d3794d3ab098ea8a2311fc2c643.tar.bz2 Ishtar-781d7824ca939d3794d3ab098ea8a2311fc2c643.zip |
Arcaheological file: adapt forms, models and sheet
-rw-r--r-- | archaeological_files/forms.py | 3 | ||||
-rw-r--r-- | archaeological_files/models.py | 14 | ||||
-rw-r--r-- | archaeological_files/templates/ishtar/blocks/window_file_nav.html | 9 | ||||
-rw-r--r-- | archaeological_files/templates/ishtar/sheet_file.html | 195 |
4 files changed, 139 insertions, 82 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index b075c6fc8..b87ef9ba5 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -47,6 +47,7 @@ from bootstrap_datepicker.widgets import DatePicker class FileSelect(TableSelect): + search_vector = forms.CharField(label=_(u"Full text search")) year = forms.IntegerField(label=_("Year")) numeric_reference = forms.IntegerField(label=_("Numeric reference")) internal_reference = forms.CharField(max_length=200, @@ -125,6 +126,7 @@ class FileSelect(TableSelect): class FileFormSelection(forms.Form): + SEARCH_AND_SELECT = True form_label = _("Archaeological file search") associated_models = {'pk': models.File} currents = {'pk': models.File} @@ -142,6 +144,7 @@ class FileFormSelection(forms.Form): raise forms.ValidationError(_(u"You should select a file.")) return cleaned_data + DATE_SOURCE = (('creation', _(u"Creation date")), ("reception", _(u"Reception date"))) diff --git a/archaeological_files/models.py b/archaeological_files/models.py index b0f53f11c..f8b3dc0ca 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -61,9 +61,12 @@ class PermitType(GeneralType): verbose_name = _(u"Permit type") verbose_name_plural = _(u"Permit types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=PermitType) post_delete.connect(post_save_cache, sender=PermitType) + if settings.COUNTRY == 'fr': class SaisineType(GeneralType, ValueGetter): delay = models.IntegerField(_(u"Delay (in days)"), default=30) @@ -104,6 +107,17 @@ class File(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, 'history_creator': 'history_creator__ishtaruser__person__pk', 'history_modifier': 'history_modifier__ishtaruser__person__pk', } + BASE_SEARCH_VECTORS = [ + 'name', 'internal_reference', 'file_type__label', 'saisine_type__label', + 'permit_type__label', 'permit_reference', 'comment', 'research_comment' + ] + INT_SEARCH_VECTORS = ['numeric_reference', 'year'] + M2M_SEARCH_VECTORS = ['towns__name'] + PARENT_SEARCH_VECTORS = [ + 'in_charge', 'general_contractor', 'corporation_general_contractor', + 'responsible_town_planning_service', 'planning_service', 'organization', + 'scientist' + ] # fields year = models.IntegerField(_(u"Year"), default=get_current_year) diff --git a/archaeological_files/templates/ishtar/blocks/window_file_nav.html b/archaeological_files/templates/ishtar/blocks/window_file_nav.html index f8b6ddb8a..d464c4af2 100644 --- a/archaeological_files/templates/ishtar/blocks/window_file_nav.html +++ b/archaeological_files/templates/ishtar/blocks/window_file_nav.html @@ -1,11 +1,8 @@ {% extends "ishtar/blocks/window_nav.html" %} {% load i18n %} {% block extra_actions %} -<a class='history-nav' href='{% url "operation_add" item.pk %}'> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-plus fa-stack-1x fa-inverse"></i> - </span> - <br/>{%trans "Add an operation for this file" %} +<a class="btn btn-secondary" href='{% url "operation_add" item.pk %}' + title="{%trans 'Add an operation for this file' %}"> + <i class="fa fa-plus"></i> {% trans "operation" %} </a> {% endblock %} diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index 6eda1124a..20684baf9 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -1,102 +1,153 @@ {% extends "ishtar/sheet.html" %} {% load i18n window_ope_tables window_field window_header %} -{% block head_title %}{% trans "Archaeological file" %}{% endblock %} - -{% block content %} +{% block head_title %}<strong>{% trans "Archaeological file" %}</strong> - {{item.full_internal_ref|default:''}}{% endblock %} +{% block toolbar %} {% if can_add_operation %} {% window_file_nav item window_id previous next %} {% else %} {% window_nav item window_id 'show-file' 'file_modify' 'show-historized-file' 'revert-file' previous next 1 %} {% endif %} -<p class='window-refs'>{{item.full_internal_ref|default:''}}</p> -<p class='window-refs'>{{item.internal_reference|default:''}}</p> -<p class='window-refs'>{{item.name|default:''}}</p> -{% include "ishtar/blocks/sheet_external_id.html" %} +{% endblock %} + +{% block content %} + +<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.full_internal_ref|default:''}}</p> + <p class='window-refs'>{{item.internal_reference|default:''}}</p> + <p class='window-refs'>{{item.name|default:''}}</p> + {% include "ishtar/blocks/sheet_external_id.html" %} + </p> + </div> + </div> + </div> +</div> + <h3>{% trans "General"%}</h3> -<ul class='form-flex'> - {% field_li "Reception date" item.reception_date|date:"DATE_FORMAT" %} +<div class="row"> + {% field_flex "Reception date" item.reception_date|date:"DATE_FORMAT" %} {% include "ishtar/blocks/sheet_creation_section.html" %} - {% comment %} {% if item.deadline_date and not item.acts %} <p><label>{%trans "Deadline"%}</label> <span class='value'>{% item.deadline_date %}</span></p> <!-- calculated deadline for some preventive files , see saisine_type, not displayed if an act as been send --> {% endif %} {% endcomment %} -{% field_li_detail "In charge" item.in_charge %} - -<li><label>{%trans "State"%}</label> <span class='value'>{% if item.is_active %}{%trans "Active file"%}</span></p> -{% else %}{%trans "Closed file"%}</span></li> - -{% if item.closing %}<li><label>{%trans "Closing date"%}</label> <span class='value'>{{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user.full_label }}</span></li>{% endif %} -{% endif %} - -{% field_li "Type" item.file_type %} - -{% if item.related_file %}<li><label>{%trans "Related file"%}</label> <span class='value'><a href='#' onclick='load_window("{% url "show-file" item.related_file.pk "" %}")'>{{ item.related_file }}</a></span></li>{% endif %} - -</ul> -{% field "Comment" item.comment "<pre>" "</pre>" %} - -{% include "ishtar/blocks/sheet_json.html" %} + {% field_flex_detail "In charge" item.in_charge %} + <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> + <dt class="col-5">{%trans "State"%}</dt> + <dd class='col-7'> + {% if item.is_active %}{%trans "Active file"%}{% else %}{%trans "Closed file"%}{% endif %} + </dd> + </div> + {% if item.closing %} + <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> + <dt class="col-5">{%trans "Closing date"%}</dt> + <dd class='col-7'> + {{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user.full_label }} + </dd> + </div> + {% endif %} + {% field_flex "Type" item.file_type %} + {% field_flex_detail "Related file" item.related_file %} + {% field_flex_full "Comment" item.comment "<pre>" "</pre>" %} + {% include "ishtar/blocks/sheet_json.html" %} +</div> <h3>{% trans "Localisation"%}</h3> -{% if item.towns.count %}<p><label>{%trans "Towns"%}</label> <span class='value'>{{ item.towns.all|join:", " }}</span></p>{% endif %} -{% if item.departments.count %}<p><label>{%trans "Departments"%}</label> <span class='value'>{{ item.departments.all|join:", " }}</span></p>{% endif %} -{% if item.address %} -<p><label>{%trans "Main address"%}</label> <span class='value'>{{ item.address }}</span></p> -{% if item.address_complement %}<p><label>{%trans "Complement"%}</label> <span class='value'>{{ item.address_complement }}</span></p>{%endif%} -{% if item.postal_code %}<p><label>{%trans "Postal code"%}</label> <span class='value'>{{ item.postal_code }}</span></p>{%endif%} -{% endif %} -{% if item.total_surface %}<p><label>{%trans "Surface"%}</label> <span class='value'>{{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha)</span></p>{%endif%} - +<div class="row"> + {% field_flex_multiple "Towns" item.towns %} + {% field_flex_multiple "Departments" item.departments %} + {% field_flex "Main address" item.address %} + {% field_flex "Complement" item.address_complement %} + {% field_flex "Postal code" item.postal_code %} + {% if item.total_surface %} + <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.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha) + </dd> + </div> + {% endif %} +</div> {% if item.is_preventive %} <h3>{% trans "Preventive archaeological file"%}</h3> -<ul class='form-flex'> -{% if item.total_developed_surface %}<li><label>{%trans "Developed surface"%}</label> <span class='value'>{{ item.total_developed_surface }} m<sup>2</sup> ({{ item.total_developed_surface_ha }} ha)</span></li>{% endif %} - -{% field_li "Saisine type" item.saisine_type %} +<div class="row"> + + {% if item.total_developed_surface %} + <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> + <dt class="col-5">{%trans "Developed surface"%}</dt> + <dd class='col-7'> + {{ item.total_developed_surface }} m<sup>2</sup> ({{ item.total_developed_surface_ha }} ha)</span></li> + </dd> + </div> + {% endif %} + + {% field_flex "Saisine type" item.saisine_type %} + + {% field_flex_detail "Responsible for planning service" item.responsible_town_planning_service %} + {% field_flex "Responsible for planning service address" item.responsible_town_planning_service.full_address %} + {% if item.town_planning_service %} + {% field_flex "Planning service organization" item.town_planning_service.full_address %} + {% else %} + {% field_flex "Planning service organization" item.responsible_town_planning_service.attached_to.full_address %} + {% endif %} + + {% field_flex "Permit type" item.permit_type %} + {% field_flex "Permit reference" item.permit_reference %} + + {% field_flex "General contractor" item.general_contractor.full_address %} + {% if item.corporation_general_contractor %} + {% field_flex "General contractor organization" item.corporation_general_contractor.full_address %} + {% else%} + {% field_flex "General contractor organization" item.general_contractor.attached_to.full_address %} + {% endif %} -{% field_li_detail "Responsible for planning service" item.responsible_town_planning_service %} -{% field_li "Responsible for planning service address" item.responsible_town_planning_service.full_address %} -{% if item.town_planning_service %} - {% field_li "Planning service organization" item.town_planning_service.full_address %} +</div> {% else %} - {% field_li "Planning service organization" item.responsible_town_planning_service.attached_to.full_address %} -{% endif %} -{% field_li "Permit type" item.permit_type %} -{% field_li "Permit reference" item.permit_reference %} +<h3>{% trans "Research archaeology"%}</h3> +<div class="row"> + {% field_flex_detail "Head scientist" item.scientist %} + {% field_flex "Requested operation type" item.requested_operation_type %} + {% field_flex_detail "Organization" item.organization %} -{% field_li "General contractor" item.general_contractor.full_address %} -{% if item.corporation_general_contractor %} - {% field_li "General contractor organization" item.corporation_general_contractor.full_address %} -{% else%} - {% field_li "General contractor organization" item.general_contractor.attached_to.full_address %} -{% endif %} + {% if item.cira_advised != None %} + {% field_flex "Passage en CIRA" item.cira_advised|yesno %} + {% endif %} -</ul> -{% else %} + {% if item.mh_register != None %} + {% field_flex "Sur Monument Historique classé" item.mh_register|yesno %} + {% endif %} -<h3>{% trans "Research archaeology"%}</h3> -{% if item.departments.count %}<p><label>{%trans "Departments"%}</label> <span class='value'>{% for department in item.departments.all %}{% if forloop.counter0 %}, {% endif %}{{ department }}{% endfor %}</span></p>{% endif %} -{% if item.scientist %}<p><label>{%trans "Head scientist"%}</label> <span class='value'>{{ item.scientist }}</span></p>{% endif %} -{% if item.requested_operation_type %}<p><label>{%trans "Requested operation type"%}</label> <span class='value'>{{ item.requested_operation_type }}</span></p>{% endif %} -{% if item.organization %}<p><label>{%trans "Organization"%}</label> <span class='value'>{{ item.organization }}</span></p>{% endif %} -{% if item.cira_advised != None %}<p><label>Passage en CIRA</label> <span class='value'>{{ item.cira_advised|yesno }}</span></p>{% endif %} -{% if item.mh_register != None %}<p><label>Sur Monument Historique classé</label> <span class='value'>{{ item.mh_register|yesno }}</span></p>{% endif %} -{% if item.mh_listing != None %}<p><label>Sur Monument Historique inscrit</label> <span class='value'>{{ item.mh_listing|yesno }}</span></p>{% endif %} -{% if item.classified_area != None %}<p><label>{% trans "Classified area" %}</label> <span class='value'>{{ item.classified_area|yesno }}</span></p>{% endif %} -{% if item.protected_area != None %}<p><label>{% trans "Protected area" %}</label> <span class='value'>{{ item.protected_area|yesno }}</span></p>{% endif %} -{% if item.research_comment %}<p><label>{%trans "Comment"%}</label> <span class='value'>{{ item.research_comment }}</span></p>{% endif %} + {% if item.mh_listing != None %} + {% field_flex "Sur Monument Historique inscrit" item.mh_listing|yesno %} + {% endif %} + + {% if item.classified_area != None %} + {% field_flex "Classified area" item.classified_area|yesno %} + {% endif %} + + {% if item.protected_area != None %} + {% field_flex "Protected area" item.protected_area|yesno %} + {% endif %} + + {% field_flex_full "Comment" item.research_comment "<pre>" "</pre>" %} +</div> {% endif %} @@ -109,9 +160,7 @@ {% table_administrativact administrativeacts_label item.administrative_act.all %} <h4>{%trans "Associated operations"%}</h4> -<div class='clean-table'> -<div class='clean-table-wrap'> -<table> +<table class="table table-striped"> <tr> <th>{% trans "Ref." %}</th> <th>Code Patriarche</th> @@ -136,13 +185,9 @@ <tr><td colspan="8" class='no_items'>{% trans "No operation associated to this archaeological file" %}</td></tr> {% endfor %} </table> -</div> -</div> <h4>{%trans "Admninistrative acts linked to associated operations"%}</h4> -<div class='clean-table'> -<div class='clean-table-wrap'> -<table> +<table class="table table-striped"> <tr> <th>{% trans "Year" %}</th> <th>{% trans "Ref." %}</th> @@ -160,8 +205,6 @@ <tr><td colspan="4" class='no_items'>{% trans "No administrative act linked to operations" %}</td></tr> {% endfor %} </table> -</div> -</div> {% endif %} {% endblock %} |