From a4d361ff9b5bf5e42610511e6194246dc7eb8c93 Mon Sep 17 00:00:00 2001 From: sergio_gimenez Date: Thu, 7 Nov 2024 08:15:42 +0100 Subject: [PATCH] Initial view of the enviromental impact without calculations --- device/environmental_impact/__init__.py | 0 device/environmental_impact/calculator.py | 10 ++++ device/templates/details.html | 59 +++++++++++++++++++++++ device/views.py | 2 + 4 files changed, 71 insertions(+) create mode 100644 device/environmental_impact/__init__.py create mode 100644 device/environmental_impact/calculator.py diff --git a/device/environmental_impact/__init__.py b/device/environmental_impact/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/device/environmental_impact/calculator.py b/device/environmental_impact/calculator.py new file mode 100644 index 0000000..dd79432 --- /dev/null +++ b/device/environmental_impact/calculator.py @@ -0,0 +1,10 @@ +from dataclasses import dataclass + + +@dataclass +class EnvironmentalImpact: + carbon_saved: float + + +def get_device_environmental_impact() -> EnvironmentalImpact: + return EnvironmentalImpact(carbon_saved=225.0) diff --git a/device/templates/details.html b/device/templates/details.html index 331c857..6af4e86 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -32,6 +32,9 @@ + @@ -229,6 +232,62 @@ {% endfor %} +
+
+ {% comment %}
Environmental Impact Assessment
{% endcomment %} + +
+
+
+
+
+ +
+
Carbon Reduction
+

{{ impact.carbon_saved }}

+

kg CO₂e saved

+
+
+
+ {% comment %}
+
+
+
+ +
+
Whatever other metric we might wanna show
+

85%

+

whatever

+
+
+
{% endcomment %} +
+
+
Impact Details
+ +
+ + + + + + + +
Manufacturing Impact Avoided + {{ impact.carbon_saved }} kg CO₂e +
+ Based on average laptop manufacturing emissions +
+
+ +
+
Calculation Method
+ Based on industry standards X Y and Z +
+
+
+
+
{% endblock %} diff --git a/device/views.py b/device/views.py index 319f8cf..1deb795 100644 --- a/device/views.py +++ b/device/views.py @@ -16,6 +16,7 @@ from evidence.models import Annotation from lot.models import LotTag from device.models import Device from device.forms import DeviceFormSet +from device.environmental_impact.calculator import get_device_environmental_impact class NewDeviceView(DashboardView, FormView): @@ -107,6 +108,7 @@ class DetailsView(DashboardView, TemplateView): 'object': self.object, 'snapshot': self.object.get_last_evidence(), 'lot_tags': lot_tags, + 'impact': get_device_environmental_impact() }) return context