diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-09-12 18:54:28 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-09-12 18:54:28 +0200 |
commit | b6da2dbc66b084cf04124878f9f3617be1cff5bf (patch) | |
tree | ded46e73d714edd9c7b1eafaead66344f6cb76d6 | |
parent | 25a0f476ef2248cde4e70ed0c199174e1398e2ba (diff) | |
download | Ishtar-b6da2dbc66b084cf04124878f9f3617be1cff5bf.tar.bz2 Ishtar-b6da2dbc66b084cf04124878f9f3617be1cff5bf.zip |
Change m2 to ha in dashboards (refs #559)
3 files changed, 28 insertions, 15 deletions
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 @@ <div class='table'> <table> - <caption>{% trans "Surface by department (m²)"%}</caption> + <caption>{% trans "Surface by department (ha)"%}</caption> <tr> {% for dpt in dashboard.rescue.surface_by_dpt %}<th>{{dpt.department__label}}</th>{% endfor %} </tr> <tr> - {% for dpt in dashboard.rescue.surface_by_dpt %}<td>{{dpt.number}}</td>{% endfor%} + {% for dpt in dashboard.rescue.surface_by_dpt %}<td>{{dpt.number|m2_to_ha}}</td>{% endfor%} </tr> </table> </div> @@ -198,12 +197,12 @@ <div class='table'> <table> - <caption>{% trans "Main towns by surface (m²)"%}</caption> + <caption>{% trans "Main towns by surface (ha)"%}</caption> <tr> {% for town in dashboard.rescue.surface_by_town %}<th>{{town.town__name}}</th>{% endfor %} </tr> <tr> - {% for town in dashboard.rescue.surface_by_town %}<td>{{town.number}}</td>{% endfor%} + {% for town in dashboard.rescue.surface_by_town %}<td>{{town.number|m2_to_ha}}</td>{% endfor%} </tr> </table> </div> 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 @@ <table> <caption>{% trans "Area by type of operation" %}</caption> <tr> - <th>{% trans "Status" %}</th><th>{% trans "Area (m²)" %}</th> + <th>{% trans "Status" %}</th><th>{% trans "Area (ha)" %}</th> </tr> {% for surface in dashboard.surface_by_type %} <tr> - <th class='sub'>{{surface.operation_type__label}}</th><td>{{surface.number}}</td> + <th class='sub'>{{surface.operation_type__label}}</th><td>{{surface.number|m2_to_ha}}</td> </tr> {% endfor %} </table></div> @@ -228,15 +227,15 @@ <div class='table'> <table> - <caption>{% trans "Effective operations areas (m²)" %}</caption> + <caption>{% trans "Effective operations areas (ha)" %}</caption> <tr> <th> </th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} </tr> <tr> - <th>{% trans "Sum" %}</th>{% for nb, mean in dashboard.survey.effective %}<td>{{nb}}</td>{% endfor %} + <th>{% trans "Sum" %}</th>{% for nb, mean in dashboard.survey.effective %}<td>{{nb|m2_to_ha}}</td>{% endfor %} </tr> <tr> - <th>{% trans "Average" %}</th>{% for nb, avg in dashboard.survey.effective %}<td>{{avg}}</td>{% endfor %} + <th>{% trans "Average" %}</th>{% for nb, avg in dashboard.survey.effective %}<td>{{avg|m2_to_ha}}</td>{% endfor %} </tr> </table></div> @@ -313,11 +312,11 @@ <table> <caption>{% trans "Main towns by surface" %}</caption> <tr> - <th>{% trans "Town" %}</th><th>{% trans "Total surface (m²)" %}</th> + <th>{% trans "Town" %}</th><th>{% trans "Total surface (ha)" %}</th> </tr> {% for lbl, nb in dashboard.survey.towns_surface %} <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + <th class='sub'>{{lbl}}</th><td>{{nb|m2_to_ha}}</td> </tr> {% endfor %} </table></div> 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) + |