Merge pull request #433 from eReuse/bugfix/4280-pdf
fix with last lot incoming
This commit is contained in:
commit
d97eb08cce
|
@ -1071,22 +1071,18 @@ class ExportsView(View):
|
||||||
if not erasures or customer_details:
|
if not erasures or customer_details:
|
||||||
return my_data, customer_details
|
return my_data, customer_details
|
||||||
|
|
||||||
init = erasures[0].device.get_set_lots()
|
lots = {erasures[0].device.get_last_incoming_lot()}
|
||||||
for e in erasures:
|
for e in erasures[1:]:
|
||||||
init = init.intersection(e.device.get_set_lots())
|
lots.add(e.device.get_last_incoming_lot())
|
||||||
|
|
||||||
if not len(init):
|
if len(lots) != 1:
|
||||||
return my_data, customer_details
|
return my_data, customer_details
|
||||||
|
|
||||||
lots = sorted(list(init), key=lambda x: x.created)
|
lot = lots.pop()
|
||||||
lots.reverse()
|
|
||||||
for lot in lots:
|
|
||||||
try:
|
try:
|
||||||
customer_details = lot.transfer.customer_details
|
customer_details = lot.transfer.customer_details
|
||||||
if customer_details:
|
|
||||||
return my_data, customer_details
|
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
pass
|
||||||
|
|
||||||
return my_data, customer_details
|
return my_data, customer_details
|
||||||
|
|
||||||
|
|
|
@ -1021,18 +1021,24 @@ class Device(Thing):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_set_lots(self):
|
def get_last_incoming_lot(self):
|
||||||
|
lots = list(self.lots)
|
||||||
if hasattr(self, "orphan") and self.orphan:
|
if hasattr(self, "orphan") and self.orphan:
|
||||||
|
lots = list(self.lots)
|
||||||
if self.binding:
|
if self.binding:
|
||||||
return set(self.binding.device.lots)
|
lots = list(self.binding.device.lots)
|
||||||
return set(self.lots)
|
|
||||||
|
|
||||||
if hasattr(self, "parent") and self.parent:
|
elif hasattr(self, "parent") and self.parent:
|
||||||
|
lots = list(self.parent.lots)
|
||||||
if self.parent.binding:
|
if self.parent.binding:
|
||||||
return set(self.parent.binding.device.lots)
|
lots = list(self.parent.binding.device.lots)
|
||||||
return set(self.parent.lots)
|
|
||||||
|
|
||||||
return set(self.lots)
|
lots = sorted(lots, key=lambda x: x.created)
|
||||||
|
lots.reverse()
|
||||||
|
for lot in lots:
|
||||||
|
if lot.is_incoming:
|
||||||
|
return lot
|
||||||
|
return None
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
return self.id < other.id
|
return self.id < other.id
|
||||||
|
|
|
@ -161,7 +161,7 @@
|
||||||
{% if erasure_hosts %}
|
{% if erasure_hosts %}
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
<td style="width:20%;">
|
<td style="width:20%;">
|
||||||
<span>SNs; of sanitization server {{ erasure_hosts|length }}:</span>
|
<span>SNs of sanitization server:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
{% for e in erasure_hosts %}
|
{% for e in erasure_hosts %}
|
||||||
|
|
Reference in New Issue