Merge pull request #440 from eReuse/feature/4174-report-devices
add lots in export devices
This commit is contained in:
commit
290c20d46e
|
@ -748,6 +748,28 @@ class Device(Thing):
|
|||
|
||||
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):
|
||||
from ereuse_devicehub.resources.device import states
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@ class BaseDeviceRow(OrderedDict):
|
|||
self['PHID'] = ''
|
||||
self['DHID'] = ''
|
||||
self['Type'] = ''
|
||||
self['Temporary Lots'] = ''
|
||||
self['Incoming Lots'] = ''
|
||||
self['Outgoing Lots'] = ''
|
||||
self['Placeholder Palet'] = ''
|
||||
self['Placeholder Id Supplier'] = ''
|
||||
self['Placeholder Info'] = ''
|
||||
|
@ -504,6 +507,9 @@ class DeviceRow(BaseDeviceRow):
|
|||
# Placeholder
|
||||
self['PHID'] = none2str(self.placeholder.phid)
|
||||
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 Id Supplier'] = none2str(self.placeholder.id_device_supplier)
|
||||
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
File diff suppressed because one or more lines are too long
|
@ -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[1][:29] == export_csv[1][:29]
|
||||
fixture_csv[1][:32] == export_csv[1][:32]
|
||||
), '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 (
|
||||
fixture_csv[1][32:] == export_csv[1][32:]
|
||||
fixture_csv[1][35:] == export_csv[1][35:]
|
||||
), '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[1][:29] == export_csv[1][:29]
|
||||
fixture_csv[1][:32] == export_csv[1][:32]
|
||||
), '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 (
|
||||
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'
|
||||
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 (
|
||||
fixture_csv[1][97:] == export_csv[1][97:]
|
||||
fixture_csv[1][100:] == export_csv[1][100:]
|
||||
), 'Computer information are not equal'
|
||||
assert (
|
||||
fixture_csv[2][:29] == export_csv[2][:29]
|
||||
fixture_csv[2][:32] == export_csv[2][:32]
|
||||
), '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 (
|
||||
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'
|
||||
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 (
|
||||
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'
|
||||
assert (
|
||||
fixture_csv[2][120] == export_csv[2][120]
|
||||
fixture_csv[2][123] == export_csv[2][123]
|
||||
), 'Computer information are not equal'
|
||||
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'
|
||||
assert (
|
||||
fixture_csv[2][146] == export_csv[2][146]
|
||||
fixture_csv[2][149] == export_csv[2][149]
|
||||
), 'Computer information are not equal'
|
||||
assert (
|
||||
fixture_csv[2][149:] == export_csv[2][149:]
|
||||
fixture_csv[2][152:] == export_csv[2][152:]
|
||||
), 'Computer information are not equal'
|
||||
|
||||
|
||||
|
|
|
@ -264,16 +264,16 @@ def test_export_devices(user3: UserClientFlask):
|
|||
|
||||
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
|
||||
assert (
|
||||
fixture_csv[1][:29] == export_csv[1][:29]
|
||||
fixture_csv[1][:32] == export_csv[1][:32]
|
||||
), '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 (
|
||||
fixture_csv[1][32:93] == export_csv[1][32:93]
|
||||
fixture_csv[1][35:96] == export_csv[1][35:96]
|
||||
), '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 (
|
||||
fixture_csv[1][98:] == export_csv[1][98:]
|
||||
fixture_csv[1][101:] == export_csv[1][101:]
|
||||
), 'Computer information are not equal'
|
||||
|
||||
|
||||
|
|
Reference in New Issue