From 7775208b284ba396e6927547e4c9c397ecf92948 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 6 Oct 2022 18:47:32 +0200 Subject: [PATCH] add prefix to lots name in the list of devices --- ereuse_devicehub/resources/device/models.py | 15 +++++++++++++++ .../templates/inventory/device_list.html | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 67f4bb80..5f1ccb20 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -653,6 +653,21 @@ class Device(Thing): args[POLYMORPHIC_ON] = cls.type return args + def get_lots_for_template(self): + lots = [] + for lot in self.lots: + if lot.is_incoming: + name = "IN - " + lot.name + lots.append(name) + if lot.is_outgoing: + name = "OUT - " + lot.name + lots.append(name) + if lot.is_temporary: + name = "TEMP - " + lot.name + lots.append(name) + lots.sort() + return lots + def phid(self): if self.placeholder: return self.placeholder.phid diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 737d556b..9e43c4ba 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -376,8 +376,8 @@ {% if dev.lots | length > 0 %}
- {% for lot in dev.lots %} - {{ lot.name }} + {% for lot in dev.get_lots_for_template() %} + {{ lot }} {% endfor %}
{% endif %}