From b6da2dbc66b084cf04124878f9f3617be1cff5bf Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 12 Sep 2013 18:54:28 +0200 Subject: Change m2 to ha in dashboards (refs #559) --- .../templates/ishtar/dashboards/dashboard_file.html | 11 +++++------ .../ishtar/dashboards/dashboard_operation.html | 17 ++++++++--------- ishtar_common/templatetags/units.py | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 ishtar_common/templatetags/units.py diff --git a/archaeological_files/templates/ishtar/dashboards/dashboard_file.html b/archaeological_files/templates/ishtar/dashboards/dashboard_file.html index 0548308c0..de8be7d30 100644 --- a/archaeological_files/templates/ishtar/dashboards/dashboard_file.html +++ b/archaeological_files/templates/ishtar/dashboards/dashboard_file.html @@ -1,6 +1,5 @@ {% extends "base.html" %} -{% load i18n %} -{% load range %} +{% load i18n range units %} {% block extra_head %} {{form.media}} {% endblock %} @@ -174,12 +173,12 @@
- + {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor %} - {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor%} + {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor%}
{% trans "Surface by department (m²)"%}{% trans "Surface by department (ha)"%}
{{dpt.department__label}}
{{dpt.number}}{{dpt.number|m2_to_ha}}
@@ -198,12 +197,12 @@
- + {% for town in dashboard.rescue.surface_by_town %}{% endfor %} - {% for town in dashboard.rescue.surface_by_town %}{% endfor%} + {% for town in dashboard.rescue.surface_by_town %}{% endfor%}
{% trans "Main towns by surface (m²)"%}{% trans "Main towns by surface (ha)"%}
{{town.town__name}}
{{town.number}}{{town.number|m2_to_ha}}
diff --git a/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html b/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html index 719ec2ac1..e67214fbf 100644 --- a/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html +++ b/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html @@ -1,6 +1,5 @@ {% extends "base.html" %} -{% load i18n %} -{% load range %} +{% load i18n range units %} {% block extra_head %} {{form.media}} {% endblock %} @@ -28,11 +27,11 @@ - + {% for surface in dashboard.surface_by_type %} - + {% endfor %}
{% trans "Area by type of operation" %}
{% trans "Status" %}{% trans "Area (m²)" %}{% trans "Status" %}{% trans "Area (ha)" %}
{{surface.operation_type__label}}{{surface.number}}{{surface.operation_type__label}}{{surface.number|m2_to_ha}}
@@ -228,15 +227,15 @@
- + {% for yr in dashboard.years%}{% endfor %} - {% for nb, mean in dashboard.survey.effective %}{% endfor %} + {% for nb, mean in dashboard.survey.effective %}{% endfor %} - {% for nb, avg in dashboard.survey.effective %}{% endfor %} + {% for nb, avg in dashboard.survey.effective %}{% endfor %}
{% trans "Effective operations areas (m²)" %}{% trans "Effective operations areas (ha)" %}
 {{yr}}
{% trans "Sum" %}{{nb}}{% trans "Sum" %}{{nb|m2_to_ha}}
{% trans "Average" %}{{avg}}{% trans "Average" %}{{avg|m2_to_ha}}
@@ -313,11 +312,11 @@ - + {% for lbl, nb in dashboard.survey.towns_surface %} - + {% endfor %}
{% trans "Main towns by surface" %}
{% trans "Town" %}{% trans "Total surface (m²)" %}{% trans "Town" %}{% trans "Total surface (ha)" %}
{{lbl}}{{nb}}{{lbl}}{{nb|m2_to_ha}}
diff --git a/ishtar_common/templatetags/units.py b/ishtar_common/templatetags/units.py new file mode 100644 index 000000000..d4d755265 --- /dev/null +++ b/ishtar_common/templatetags/units.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from django.template import Library + +register = Library() + +@register.filter +def m2_to_ha(value): + try: + value = float(value)/10000 + except: + return "" + return "%.2f" % round(value, 2) + -- cgit v1.2.3