From 2a8da254d9d8de8ed8615b23334eded2493a838c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 25 Oct 2022 17:54:58 +0200 Subject: [PATCH 1/3] fix image in edit device --- ereuse_devicehub/inventory/forms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 5cc43bfc..3dcd0924 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -353,7 +353,7 @@ class NewDeviceForm(FlaskForm): depth = FloatField('Depth', [validators.Optional()]) variant = StringField('Variant', [validators.Optional()]) sku = StringField('SKU', [validators.Optional()]) - image = StringField('Image', [validators.Optional(), validators.URL()]) + image = URLField('Image', [validators.Optional(), validators.URL()]) imei = IntegerField('IMEI', [validators.Optional()]) meid = StringField('MEID', [validators.Optional()]) resolution = IntegerField('Resolution width', [validators.Optional()]) @@ -413,7 +413,7 @@ class NewDeviceForm(FlaskForm): self.depth.data = self._obj.depth self.variant.data = self._obj.variant self.sku.data = self._obj.sku - self.image.data = self._obj.image + self.image.data = self._obj.image.to_text() if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']: self.imei.data = self._obj.imei self.meid.data = self._obj.meid @@ -614,7 +614,7 @@ class NewDeviceForm(FlaskForm): self._obj.height = self.height.data self._obj.depth = self.depth.data self._obj.variant = self.variant.data - self._obj.image = self.image.data + self._obj.image = URL(self.image.data) if self._obj.type == 'ComputerMonitor': self._obj.resolution_width = self.resolution.data From e30990cc1bfb72dbbbb3429bab982cb52d1609f8 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 26 Oct 2022 09:33:28 +0200 Subject: [PATCH 2/3] fix render image None --- ereuse_devicehub/inventory/forms.py | 5 ++++- tests/test_render_2_0.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 3dcd0924..2eb7c716 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -413,7 +413,8 @@ class NewDeviceForm(FlaskForm): self.depth.data = self._obj.depth self.variant.data = self._obj.variant self.sku.data = self._obj.sku - self.image.data = self._obj.image.to_text() + if self._obj.image: + self.image.data = self._obj.image.to_text() if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']: self.imei.data = self._obj.imei self.meid.data = self._obj.meid @@ -559,6 +560,8 @@ class NewDeviceForm(FlaskForm): device.imei = self.imei.data device.meid = self.meid.data + device.image = URL(self.image.data) + device.placeholder = self.get_placeholder() db.session.add(device) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 3ac8d4e9..765c05ef 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -2174,6 +2174,7 @@ def test_manual_binding(user3: UserClientFlask): @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) def test_edit_and_binding(user3: UserClientFlask): + # TODO uri = '/inventory/device/add/' user3.get(uri) @@ -2587,7 +2588,7 @@ def test_system_uuid_motherboard(user3: UserClientFlask): # we want to do an snapshot log when there are the same system-uuid for # 2 computers with diferent motherboard snapshot = create_device(user3, 'real-eee-1001pxd.snapshot.12.json') - device = snapshot.device + # device = snapshot.device uri = '/inventory/upload-snapshot/' file_name = 'real-eee-1001pxd.snapshot.12' From 7c4a3bd770ec4d108b64cad9c1cc0ba3db1e4955 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 26 Oct 2022 09:43:01 +0200 Subject: [PATCH 3/3] tests --- tests/test_render_2_0.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 765c05ef..be02faf2 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -2588,7 +2588,7 @@ def test_system_uuid_motherboard(user3: UserClientFlask): # we want to do an snapshot log when there are the same system-uuid for # 2 computers with diferent motherboard snapshot = create_device(user3, 'real-eee-1001pxd.snapshot.12.json') - # device = snapshot.device + device = snapshot.device uri = '/inventory/upload-snapshot/' file_name = 'real-eee-1001pxd.snapshot.12'