From da5f5cbd97ad34ccd95b2ce366e03fbe28626ac3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 21 Jan 2018 21:05:28 +0100 Subject: Arcaheological file: adapt forms, models and sheet --- archaeological_files/forms.py | 3 + archaeological_files/models.py | 14 ++ .../templates/ishtar/blocks/window_file_nav.html | 9 +- .../templates/ishtar/sheet_file.html | 195 +++++++++++++-------- 4 files changed, 139 insertions(+), 82 deletions(-) (limited to 'archaeological_files') 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 %} - - - - - -
{%trans "Add an operation for this file" %} +
+ {% trans "operation" %} {% 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 %}{% trans "Archaeological file" %} - {{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 %} -

{{item.full_internal_ref|default:''}}

-

{{item.internal_reference|default:''}}

-

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

-{% include "ishtar/blocks/sheet_external_id.html" %} +{% endblock %} + +{% block content %} + +
+
+
+ {% if item.image %} + + {% endif%} +
+

+

{{item.full_internal_ref|default:''}}

+

{{item.internal_reference|default:''}}

+

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

+ {% include "ishtar/blocks/sheet_external_id.html" %} +

+
+
+
+
+

{% trans "General"%}

- -{% field "Comment" item.comment "
" "
" %} - -{% include "ishtar/blocks/sheet_json.html" %} + {% field_flex_detail "In charge" item.in_charge %} +
+
{%trans "State"%}
+
+ {% if item.is_active %}{%trans "Active file"%}{% else %}{%trans "Closed file"%}{% endif %} +
+
+ {% if item.closing %} +
+
{%trans "Closing date"%}
+
+ {{ item.closing.date }} {%trans "by" %} {{ item.closing.user.full_label }} +
+
+ {% endif %} + {% field_flex "Type" item.file_type %} + {% field_flex_detail "Related file" item.related_file %} + {% field_flex_full "Comment" item.comment "
" "
" %} + {% include "ishtar/blocks/sheet_json.html" %} +

{% trans "Localisation"%}

-{% if item.towns.count %}

{{ item.towns.all|join:", " }}

{% endif %} -{% if item.departments.count %}

{{ item.departments.all|join:", " }}

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

{{ item.address }}

-{% if item.address_complement %}

{{ item.address_complement }}

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

{{ item.postal_code }}

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

{{ item.total_surface }} m2 ({{ item.total_surface_ha }} ha)

{%endif%} - +
+ {% 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 %} +
+
{%trans "Surface"%}
+
+ {{ item.total_surface }} m2 ({{ item.total_surface_ha }} ha) +
+
+ {% endif %} +
{% if item.is_preventive %}

{% trans "Preventive archaeological file"%}

- -{% else %} + {% if item.mh_register != None %} + {% field_flex "Sur Monument Historique classé" item.mh_register|yesno %} + {% endif %} -

{% trans "Research archaeology"%}

-{% if item.departments.count %}

{% for department in item.departments.all %}{% if forloop.counter0 %}, {% endif %}{{ department }}{% endfor %}

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

{{ item.scientist }}

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

{{ item.requested_operation_type }}

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

{{ item.organization }}

{% endif %} -{% if item.cira_advised != None %}

{{ item.cira_advised|yesno }}

{% endif %} -{% if item.mh_register != None %}

{{ item.mh_register|yesno }}

{% endif %} -{% if item.mh_listing != None %}

{{ item.mh_listing|yesno }}

{% endif %} -{% if item.classified_area != None %}

{{ item.classified_area|yesno }}

{% endif %} -{% if item.protected_area != None %}

{{ item.protected_area|yesno }}

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

{{ item.research_comment }}

{% 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 "
" "
" %} + {% endif %} @@ -109,9 +160,7 @@ {% table_administrativact administrativeacts_label item.administrative_act.all %}

{%trans "Associated operations"%}

-
-
- +
@@ -136,13 +185,9 @@ {% endfor %}
{% trans "Ref." %} Code Patriarche
{% trans "No operation associated to this archaeological file" %}
-
-

{%trans "Admninistrative acts linked to associated operations"%}

-
-
- +
@@ -160,8 +205,6 @@ {% endfor %}
{% trans "Year" %} {% trans "Ref." %}
{% trans "No administrative act linked to operations" %}
-
-
{% endif %} {% endblock %} -- cgit v1.2.3