add prefix to lots name in the list of devices

This commit is contained in:
Cayo Puigdefabregas 2022-10-06 18:47:32 +02:00
parent fbf70aac89
commit 7775208b28
2 changed files with 17 additions and 2 deletions

View File

@ -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

View File

@ -376,8 +376,8 @@
</a>
{% if dev.lots | length > 0 %}
<h6 class="d-inline">
{% for lot in dev.lots %}
<span class="badge rounded-pill bg-light text-dark">{{ lot.name }}</span>
{% for lot in dev.get_lots_for_template() %}
<span class="badge rounded-pill bg-light text-dark">{{ lot }}</span>
{% endfor %}
</h6>
{% endif %}