summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operation.html12
-rw-r--r--ishtar_common/templatetags/ishtar_helpers.py16
2 files changed, 23 insertions, 5 deletions
diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html
index 1e7d3dc78..9153454fd 100644
--- a/archaeological_operations/templates/ishtar/sheet_operation.html
+++ b/archaeological_operations/templates/ishtar/sheet_operation.html
@@ -20,14 +20,16 @@
{% with permission_view_own_container=permission_view_own_container %}
{% with display_data=item.data %}
-{% with display_relations=item.right_relations.count|or_:item.left_relations.count %}
-{% with display_sites=item.archaeological_sites.count|or_:item.grouped_parcels|or_:item.administrative_act.count %}
+{% with display_relations=item|safe_or:"right_relations.count|left_relations.count" %}
+{% with display_sites=item|safe_or:"archaeological_sites.count|grouped_parcels|administrative_act.count" %}
{% with perm_documents=permission_view_own_document|or_:permission_view_document %}
{% with display_documents=perm_documents|and_:item.documents.count %}
{% with perm_context_records=permission_view_own_contextrecord|or_:permission_view_contextrecord %}
-{% with display_context_records=perm_context_records|and_:item.context_record.count %}
+{% with has_context_records=item|safe_or:"context_record.count" %}
+{% with display_context_records=perm_context_records|and_:has_context_records %}
{% with perm_find=permission_view_own_find|or_:permission_view_find %}
-{% with display_finds=perm_find|and_:item.has_finds %}
+{% with has_finds=item|safe_or:"has_finds" %}
+{% with display_finds=perm_find|and_:has_finds %}
{% if output != "ODT" and output != "PDF"%}
<ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist">
@@ -488,6 +490,6 @@
</div>
</div>
-{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %}
+{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %}
{% endblock %} \ No newline at end of file
diff --git a/ishtar_common/templatetags/ishtar_helpers.py b/ishtar_common/templatetags/ishtar_helpers.py
index 51f5e722e..282f35521 100644
--- a/ishtar_common/templatetags/ishtar_helpers.py
+++ b/ishtar_common/templatetags/ishtar_helpers.py
@@ -18,6 +18,22 @@ def and_(value1, value2):
@register.filter
+def safe_or(item, args):
+ if not item:
+ return False
+ for arg in args.split("|"):
+ result = True
+ current_item = item
+ for sub in arg.split("."):
+ if not hasattr(current_item, sub) or not getattr(current_item, sub):
+ result = False
+ break
+ current_item = getattr(current_item, sub)
+ if result:
+ return True
+
+
+@register.filter
def file_content(value):
if value:
return mark_safe(value.read())