From b737aaf50a9ff34d5840b240a9c58ad1d8cfda29 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 4 Mar 2022 13:31:33 +0100 Subject: [PATCH] add verbose_name in device.model instead of use template system --- ereuse_devicehub/resources/device/models.py | 7 +++++++ ereuse_devicehub/templates/inventory/device_list.html | 2 +- ereuse_devicehub/templates/inventory/tag_detail.html | 2 +- ereuse_devicehub/templates/inventory/tag_list.html | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 16b9df5b..89ddc846 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -474,6 +474,13 @@ class Device(Thing): key=attrgetter('type')) # last test of each type return self._warning_actions(current_tests) + @property + def verbose_name(self): + type = self.type or '' + manufacturer = self.manufacturer or '' + model = self.model or '' + return f'{type} {manufacturer} {model}' + @declared_attr def __mapper_args__(cls): """Defines inheritance. diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 3cf54939..80384cb1 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -316,7 +316,7 @@ - {{ dev.type }} {{ dev.manufacturer|d('', true) }} {{ dev.model|d('', true) }} + {{ dev.verbose_name }} diff --git a/ereuse_devicehub/templates/inventory/tag_detail.html b/ereuse_devicehub/templates/inventory/tag_detail.html index 356220d5..3e63ff50 100644 --- a/ereuse_devicehub/templates/inventory/tag_detail.html +++ b/ereuse_devicehub/templates/inventory/tag_detail.html @@ -34,7 +34,7 @@
{% if tag.device %} - {{ tag.device.type }} {{ tag.device.manufacturer|d('', true) }} {{ tag.device.model|d('', true) }} + {{ tag.device.verbose_name }} {% endif %}
diff --git a/ereuse_devicehub/templates/inventory/tag_list.html b/ereuse_devicehub/templates/inventory/tag_list.html index 519debab..b385dfc8 100644 --- a/ereuse_devicehub/templates/inventory/tag_list.html +++ b/ereuse_devicehub/templates/inventory/tag_list.html @@ -58,7 +58,7 @@ {% if tag.device %} - {{ tag.device.type }} {{ tag.device.manufacturer|d('', true) }} {{ tag.device.model|d('', true) }} + {{ tag.device.verbose_name }} {% endif %}