Merge pull request #446 from eReuse/changes/4217-add-columns-export-devices

Bugfix/4217 fix id supplier column in export devices
This commit is contained in:
cayop 2023-04-21 17:17:42 +02:00 committed by GitHub
commit 9da841fc1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 34 deletions

View File

@ -468,8 +468,6 @@ class NewDeviceForm(FlaskForm):
if self._obj.placeholder.is_abstract:
self.type.render_kw = disabled
self.amount.render_kw = disabled
# self.id_device_supplier.render_kw = disabled
self.pallet.render_kw = disabled
self.info.render_kw = disabled
self.components.render_kw = disabled
self.serial_number.render_kw = disabled
@ -683,6 +681,14 @@ class NewDeviceForm(FlaskForm):
):
self._obj.set_functionality(self.functionality.data)
else:
self._obj.placeholder.id_device_supplier = (
self.id_device_supplier.data or None
)
self._obj.placeholder.id_device_internal = (
self.id_device_internal.data or None
)
self._obj.placeholder.pallet = self.pallet.data or None
placeholder_log = PlaceholdersLog(
type="Update", source='Web form', placeholder=self._obj.placeholder
)

View File

@ -40,8 +40,9 @@ class BaseDeviceRow(OrderedDict):
self['Temporary Lots'] = ''
self['Incoming Lots'] = ''
self['Outgoing Lots'] = ''
self['Placeholder Palet'] = ''
self['Placeholder Pallet'] = ''
self['Placeholder Id Supplier'] = ''
self['Placeholder Id Internal'] = ''
self['Placeholder Info'] = ''
self['Placeholder Components'] = ''
self['Placeholder Type'] = ''
@ -266,7 +267,7 @@ class BaseDeviceRow(OrderedDict):
class DeviceRow(BaseDeviceRow):
def __init__(self, device: d.Device, document_ids: dict) -> None:
def __init__(self, device: d.Device, document_ids: dict) -> None: # noqa: C901
super().__init__()
self.placeholder = device.binding or device.placeholder
self.device = self.placeholder.binding or self.placeholder.device
@ -510,8 +511,9 @@ class DeviceRow(BaseDeviceRow):
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 Pallet'] = none2str(self.placeholder.pallet)
self['Placeholder Id Supplier'] = none2str(self.placeholder.id_device_supplier)
self['Placeholder Id Internal'] = none2str(self.placeholder.id_device_internal)
self['Placeholder Info'] = none2str(self.placeholder.info)
self['Placeholder Components'] = none2str(self.placeholder.components)
self['Placeholder Type'] = none2str(self.placeholder.device.type)

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

View File

@ -265,11 +265,11 @@ def test_export_basic_snapshot(user: UserClient):
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert (
fixture_csv[1][:32] == export_csv[1][:32]
fixture_csv[1][:33] == export_csv[1][:33]
), 'Computer information are not equal'
assert fixture_csv[1][33] == export_csv[1][33], 'Computer information are not equal'
assert fixture_csv[1][34] == export_csv[1][34], 'Computer information are not equal'
assert (
fixture_csv[1][35:] == export_csv[1][35:]
fixture_csv[1][36:] == export_csv[1][36:]
), 'Computer information are not equal'
@ -335,38 +335,38 @@ def test_export_extended(app: Devicehub, user: UserClient):
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert (
fixture_csv[1][:32] == export_csv[1][:32]
fixture_csv[1][:33] == export_csv[1][:33]
), 'Computer information are not equal'
assert fixture_csv[1][33] == export_csv[1][33], 'Computer information are not equal'
assert fixture_csv[1][34] == export_csv[1][34], 'Computer information are not equal'
assert (
fixture_csv[1][35:93] == export_csv[1][35:93]
fixture_csv[1][36:94] == export_csv[1][36: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], 'Computer information are not equal'
assert (
fixture_csv[1][100:] == export_csv[1][100:]
fixture_csv[1][101:] == export_csv[1][101:]
), 'Computer information are not equal'
assert (
fixture_csv[2][:32] == export_csv[2][:32]
fixture_csv[2][:33] == export_csv[2][:33]
), 'Computer information are not equal'
assert fixture_csv[2][33] == export_csv[2][33], 'Computer information are not equal'
assert fixture_csv[2][34] == export_csv[2][34], 'Computer information are not equal'
assert (
fixture_csv[2][35:96] == export_csv[2][35:96]
fixture_csv[2][36:97] == export_csv[2][36:97]
), 'Computer information are not equal'
assert fixture_csv[2][97] == export_csv[2][97], 'Computer information are not equal'
assert fixture_csv[2][98] == export_csv[2][98], 'Computer information are not equal'
assert (
fixture_csv[2][100:110] == export_csv[2][100:110]
fixture_csv[2][101:111] == export_csv[2][101:111]
), 'Computer information are not equal'
assert (
fixture_csv[2][123] == export_csv[2][123]
fixture_csv[2][124] == export_csv[2][124]
), 'Computer information are not equal'
assert (
fixture_csv[2][126:147] == export_csv[2][126:147]
fixture_csv[2][127:148] == export_csv[2][127:148]
), 'Computer information are not equal'
assert (
fixture_csv[2][149] == export_csv[2][149]
fixture_csv[2][150] == export_csv[2][150]
), 'Computer information are not equal'
assert (
fixture_csv[2][152:] == export_csv[2][152:]
fixture_csv[2][153:] == export_csv[2][153:]
), 'Computer information are not equal'

View File

@ -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][:32] == export_csv[1][:32]
fixture_csv[1][:33] == export_csv[1][:33]
), 'Computer information are not equal'
assert fixture_csv[1][33] == export_csv[1][33], 'Computer information are not equal'
assert fixture_csv[1][34] == export_csv[1][34], 'Computer information are not equal'
assert (
fixture_csv[1][35:96] == export_csv[1][35:96]
fixture_csv[1][36:97] == export_csv[1][36:97]
), '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], 'Computer information are not equal'
assert (
fixture_csv[1][101:] == export_csv[1][101:]
fixture_csv[1][102:] == export_csv[1][102:]
), 'Computer information are not equal'