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:
commit
1d48515008
|
@ -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
|
||||||
|
|
|
@ -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 %}
|
||||||
|
|
Reference in New Issue