add lots in export devices

This commit is contained in:
Cayo Puigdefabregas 2023-03-27 16:34:25 +02:00
parent e624ab7a7a
commit 745b9966df
5 changed files with 50 additions and 22 deletions

View File

@ -748,6 +748,28 @@ class Device(Thing):
return '' return ''
def get_lots_from_type(self, lot_type):
lots_type = {
'temporary': lambda x: x.is_temporary,
'incoming': lambda x: x.is_incoming,
'outgoing': lambda x: x.is_outgoing,
}
if lot_type not in lots_type:
return ''
get_lots_type = lots_type[lot_type]
lots = self.lots
if not lots and self.binding:
lots = self.binding.device.lots
if lots:
lots = [lot.name for lot in lots if get_lots_type(lot)]
return ", ".join(sorted(lots))
return ''
def is_status(self, action): def is_status(self, action):
from ereuse_devicehub.resources.device import states from ereuse_devicehub.resources.device import states

View File

@ -37,6 +37,9 @@ class BaseDeviceRow(OrderedDict):
self['PHID'] = '' self['PHID'] = ''
self['DHID'] = '' self['DHID'] = ''
self['Type'] = '' self['Type'] = ''
self['Temporary Lots'] = ''
self['Incoming Lots'] = ''
self['Outgoing Lots'] = ''
self['Placeholder Palet'] = '' self['Placeholder Palet'] = ''
self['Placeholder Id Supplier'] = '' self['Placeholder Id Supplier'] = ''
self['Placeholder Info'] = '' self['Placeholder Info'] = ''
@ -504,6 +507,9 @@ class DeviceRow(BaseDeviceRow):
# Placeholder # Placeholder
self['PHID'] = none2str(self.placeholder.phid) self['PHID'] = none2str(self.placeholder.phid)
self['Type'] = none2str(self.device.is_abstract()) self['Type'] = none2str(self.device.is_abstract())
self['Temporary Lots'] = none2str(self.device.get_lots_from_type('temporary'))
self['Incoming Lots'] = none2str(self.device.get_lots_from_type('incoming'))
self['Outgoing Lots'] = none2str(self.device.get_lots_from_type('outgoing'))
self['Placeholder Palet'] = none2str(self.placeholder.pallet) self['Placeholder Palet'] = none2str(self.placeholder.pallet)
self['Placeholder Id Supplier'] = none2str(self.placeholder.id_device_supplier) self['Placeholder Id Supplier'] = none2str(self.placeholder.id_device_supplier)
self['Placeholder Info'] = none2str(self.placeholder.info) self['Placeholder Info'] = none2str(self.placeholder.info)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -269,11 +269,11 @@ def test_export_basic_snapshot(user: UserClient):
assert fixture_csv[0] == export_csv[0], 'Headers are not equal' assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert ( assert (
fixture_csv[1][:29] == export_csv[1][:29] fixture_csv[1][:32] == export_csv[1][:32]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert fixture_csv[1][30] == export_csv[1][30], 'Computer information are not equal' assert fixture_csv[1][33] == export_csv[1][33], 'Computer information are not equal'
assert ( assert (
fixture_csv[1][32:] == export_csv[1][32:] fixture_csv[1][35:] == export_csv[1][35:]
), 'Computer information are not equal' ), 'Computer information are not equal'
@ -339,38 +339,38 @@ def test_export_extended(app: Devicehub, user: UserClient):
assert fixture_csv[0] == export_csv[0], 'Headers are not equal' assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert ( assert (
fixture_csv[1][:29] == export_csv[1][:29] fixture_csv[1][:32] == export_csv[1][:32]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert fixture_csv[1][30] == export_csv[1][30], 'Computer information are not equal' assert fixture_csv[1][33] == export_csv[1][33], 'Computer information are not equal'
assert ( assert (
fixture_csv[1][32:93] == export_csv[1][32:93] fixture_csv[1][35:93] == export_csv[1][35:93]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert fixture_csv[1][94] == export_csv[1][94], 'Computer information are not equal' assert fixture_csv[1][97] == export_csv[1][97], 'Computer information are not equal'
assert ( assert (
fixture_csv[1][97:] == export_csv[1][97:] fixture_csv[1][100:] == export_csv[1][100:]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert ( assert (
fixture_csv[2][:29] == export_csv[2][:29] fixture_csv[2][:32] == export_csv[2][:32]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert fixture_csv[2][30] == export_csv[2][30], 'Computer information are not equal' assert fixture_csv[2][33] == export_csv[2][33], 'Computer information are not equal'
assert ( assert (
fixture_csv[2][32:93] == export_csv[2][32:93] fixture_csv[2][35:96] == export_csv[2][35:96]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert fixture_csv[2][94] == export_csv[2][94], 'Computer information are not equal' assert fixture_csv[2][97] == export_csv[2][97], 'Computer information are not equal'
assert ( assert (
fixture_csv[2][97:107] == export_csv[2][97:107] fixture_csv[2][100:110] == export_csv[2][100:110]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert ( assert (
fixture_csv[2][120] == export_csv[2][120] fixture_csv[2][123] == export_csv[2][123]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert ( assert (
fixture_csv[2][123:144] == export_csv[2][123:144] fixture_csv[2][126:147] == export_csv[2][126:147]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert ( assert (
fixture_csv[2][146] == export_csv[2][146] fixture_csv[2][149] == export_csv[2][149]
), 'Computer information are not equal' ), 'Computer information are not equal'
assert ( assert (
fixture_csv[2][149:] == export_csv[2][149:] fixture_csv[2][152:] == export_csv[2][152:]
), 'Computer information are not equal' ), 'Computer information are not equal'