Merge pull request #377 from eReuse/features/3842-prefix-lots-in-device-list

add prefix to lots name in the list of devices
This commit is contained in:
cayop 2022-10-06 19:13:22 +02:00 committed by GitHub
commit 1d48515008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 %}