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 args[POLYMORPHIC_ON] = cls.type
return args 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): def phid(self):
if self.placeholder: if self.placeholder:
return self.placeholder.phid return self.placeholder.phid

View File

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