From 95ca7db2c23a3d13800ebe794355a12699bb7944 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 5 Jul 2011 15:15:41 +0200 Subject: Display cost on Operation sheet (closes #442) --- ishtar/ishtar_base/models.py | 18 ++++++++++++++++++ ishtar/templates/sheet_operation.html | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'ishtar') diff --git a/ishtar/ishtar_base/models.py b/ishtar/ishtar_base/models.py index 1e9cf9b21..42b79f163 100644 --- a/ishtar/ishtar_base/models.py +++ b/ishtar/ishtar_base/models.py @@ -685,6 +685,24 @@ class Operation(BaseHistorizedItem, OwnPerms): def is_own(self, person): return False + + @property + def surface_ha(self): + if self.surface: + return self.surface/10000.0 + + @property + def cost_by_m2(self): + if not self.surface or not self.cost: + return + return round(float(self.cost)/self.surface, 2) + + @property + def cost_by_m2(self): + if not self.surface or not self.cost: + return + return round(float(self.cost)/self.surface, 2) + @classmethod def get_query_owns(cls, user): return Q(in_charge=user.person)|Q(history_modifier=user)\ diff --git a/ishtar/templates/sheet_operation.html b/ishtar/templates/sheet_operation.html index 1fb2850c1..1b6755385 100644 --- a/ishtar/templates/sheet_operation.html +++ b/ishtar/templates/sheet_operation.html @@ -22,8 +22,8 @@

{{ item.closing.date }} {%trans "by" %} {{ item.closing.user }}

{% endif %}

{{ item.operation_type }}

-{#

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

#} -{% if item.cost %}

{{ item.cost }} Euros, ({{ item.cost_by_m2 }} Euros/m2)

{%endif%} +{% if item.surface %}

{{ item.surface }} m2 ({{ item.surface_ha }} ha)

{% endif %} +{% if item.cost %}

{{ item.cost }} €{% if item.cost_by_m2 %}, ({{ item.cost_by_m2 }} €/m2){%endif%}

{%endif%} {% if item.duration %}

{{ item.duration }} {%trans "Day"%}s

{%endif%}

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

-- cgit v1.2.3