diff options
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_find.html | 29 | ||||
| -rw-r--r-- | ishtar_common/templatetags/ishtar_helpers.py | 19 | 
2 files changed, 41 insertions, 7 deletions
| diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index 66fcca33e..ee0e67f2e 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -1,5 +1,5 @@  {% extends "ishtar/sheet.html" %} -{% load i18n window_field from_dict link_to_window window_tables window_header humanize %} +{% load i18n ishtar_helpers window_field from_dict link_to_window window_tables window_header humanize %}  {% block head_title %}<strong>{% trans "Find" %}</strong>{% if item.denomination %} - {{item.denomination|default:""}}{% endif %} - {{item.label|default:""}}{% endblock %} @@ -15,6 +15,11 @@  </div>  {% endif %} +{% with display_identification=item.integrities.count|or_:item.remarkabilities.count|or_:item.conservatory_state|or_:item.conservatory_comment|or_:item.alterations.count|or_:item.alteration_causes.count|or_:item.preservation_to_considers.count|or_:item.appraisal_date|or_:item.treatment_emergency|or_:item.insurance_value|or_:item.estimated_value|or_:item.datings.count|or_:item.dating_comment %} +{% with display_warehouse_treatments=item.container|or_:item.container_ref|or_:item.upstream_treatment|or_:item.downstream_treatment|or_:item.treatments.count %} +{% with can_view_documents=permission_view_own_document|or_:permission_view_document %} +{% with display_documents=can_view_documents|and_:item.documents.count %} +  <ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist">      <li class="nav-item">          <a class="nav-link active" id="{{window_id}}-basefind-tab" @@ -30,7 +35,7 @@              {% trans "Identification / Description / Dimensions" %}          </a>      </li> -    {% if item.integrities.count or item.remarkabilities.count or item.conservatory_state or item.conservatory_comment or item.alterations.count or item.alteration_causes.count or item.preservation_to_considers.count or item.appraisal_date or item.treatment_emergency or item.insurance_value or item.estimated_value or item.datings.count or item.dating_comment %} +    {% if display_identification %}      <li class="nav-item">          <a class="nav-link" id="{{window_id}}-preservation-tab"             data-toggle="tab" href="#{{window_id}}-preservation" role="tab" @@ -39,7 +44,7 @@          </a>      </li>      {% endif %} -    {% if item.container or item.container_ref or item.upstream_treatment or item.downstream_treatment or item.treatments.count %} +    {% if display_warehouse_treatments %}      <li class="nav-item">          <a class="nav-link" id="{{window_id}}-warehouse-tab"             data-toggle="tab" href="#{{window_id}}-warehouse" role="tab" @@ -48,7 +53,7 @@          </a>      </li>      {% endif %} -    {% if permission_view_own_document or permission_view_document %}{% if item.documents.count %} +    {% if display_documents %}      <li class="nav-item">          <a class="nav-link" id="{{window_id}}-documents-tab"             data-toggle="tab" href="#{{window_id}}-documents" role="tab" @@ -56,7 +61,8 @@              {% trans "Documents" %}          </a>      </li> -    {% endif %}{% endif %} +    {% endif %} +    {% if item.data %}      <li class="nav-item">          <a class="nav-link" id="{{window_id}}-json-tab"             data-toggle="tab" href="#{{window_id}}-json" role="tab" @@ -64,6 +70,7 @@              {% trans "Custom fields" %}          </a>      </li> +    {% endif %}  </ul>  <div class="tab-content" id="{{window_id}}-tab-content"> @@ -169,6 +176,7 @@            {% include "ishtar/blocks/sheet_creation_section.html" %}        </div>    </div> +  {% if display_identification %}    <div class="tab-pane fade" id="{{window_id}}-preservation"         role="tabpanel" aria-labelledby="{{window_id}}-preservation-tab">        {% if item.integrities.count or item.remarkabilities.count or item.conservatory_state or item.conservatory_comment or item.alterations.count or item.alteration_causes.count or item.preservation_to_considers.count or item.appraisal_date or item.treatment_emergency or item.insurance_value or item.estimated_value %} @@ -227,6 +235,8 @@        {% field_flex_full "Comment on dating" item.dating_comment "<pre>" "</pre>" %}        {% endif %}    </div> +  {% endif %} +  {% if display_warehouse_treatments %}    <div class="tab-pane fade" id="{{window_id}}-warehouse"         role="tabpanel" aria-labelledby="{{window_id}}-warehouse-tab">        {% if item.container_ref %} @@ -365,18 +375,23 @@        {% endif %}        {% endif %}    </div> -  {% if permission_view_own_document or permission_view_document %}{% if item.documents.count %} +  {% endif %} +  {% if display_documents %}    <div class="tab-pane fade" id="{{window_id}}-documents"         role="tabpanel" aria-labelledby="{{window_id}}-documents-tab">        {% trans "Associated documents" as finds_docs %}        {% dynamic_table_document finds_docs 'documents' 'finds' item.pk '' output %}    </div> -  {% endif %}{% endif %} +  {% endif %} +  {% if item.data %}    <div class="tab-pane fade" id="{{window_id}}-json"         role="tabpanel" aria-labelledby="{{window_id}}-json-tab">        {% include "ishtar/blocks/sheet_json.html" %}    </div> +  {% endif %}  </div> +{% endwith %}{% endwith %}{% endwith %}{% endwith %} +  {% endblock %} diff --git a/ishtar_common/templatetags/ishtar_helpers.py b/ishtar_common/templatetags/ishtar_helpers.py new file mode 100644 index 000000000..88dd68b57 --- /dev/null +++ b/ishtar_common/templatetags/ishtar_helpers.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from datetime import datetime + +from django.template import Library +from django.utils.translation import ugettext as _ + +register = Library() + + +@register.filter +def or_(value1, value2): +    return value1 or value2 + + +@register.filter +def and_(value1, value2): +    return value1 and value2 | 
