Merge pull request #390 from eReuse/bugfix/edit-placeholder
fix image in edit device
This commit is contained in:
commit
0aa4696fe0
|
@ -353,7 +353,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
depth = FloatField('Depth', [validators.Optional()])
|
depth = FloatField('Depth', [validators.Optional()])
|
||||||
variant = StringField('Variant', [validators.Optional()])
|
variant = StringField('Variant', [validators.Optional()])
|
||||||
sku = StringField('SKU', [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()])
|
imei = IntegerField('IMEI', [validators.Optional()])
|
||||||
meid = StringField('MEID', [validators.Optional()])
|
meid = StringField('MEID', [validators.Optional()])
|
||||||
resolution = IntegerField('Resolution width', [validators.Optional()])
|
resolution = IntegerField('Resolution width', [validators.Optional()])
|
||||||
|
@ -413,7 +413,8 @@ class NewDeviceForm(FlaskForm):
|
||||||
self.depth.data = self._obj.depth
|
self.depth.data = self._obj.depth
|
||||||
self.variant.data = self._obj.variant
|
self.variant.data = self._obj.variant
|
||||||
self.sku.data = self._obj.sku
|
self.sku.data = self._obj.sku
|
||||||
self.image.data = self._obj.image
|
if self._obj.image:
|
||||||
|
self.image.data = self._obj.image.to_text()
|
||||||
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
||||||
self.imei.data = self._obj.imei
|
self.imei.data = self._obj.imei
|
||||||
self.meid.data = self._obj.meid
|
self.meid.data = self._obj.meid
|
||||||
|
@ -559,6 +560,8 @@ class NewDeviceForm(FlaskForm):
|
||||||
device.imei = self.imei.data
|
device.imei = self.imei.data
|
||||||
device.meid = self.meid.data
|
device.meid = self.meid.data
|
||||||
|
|
||||||
|
device.image = URL(self.image.data)
|
||||||
|
|
||||||
device.placeholder = self.get_placeholder()
|
device.placeholder = self.get_placeholder()
|
||||||
db.session.add(device)
|
db.session.add(device)
|
||||||
|
|
||||||
|
@ -614,7 +617,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
self._obj.height = self.height.data
|
self._obj.height = self.height.data
|
||||||
self._obj.depth = self.depth.data
|
self._obj.depth = self.depth.data
|
||||||
self._obj.variant = self.variant.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':
|
if self._obj.type == 'ComputerMonitor':
|
||||||
self._obj.resolution_width = self.resolution.data
|
self._obj.resolution_width = self.resolution.data
|
||||||
|
|
|
@ -2174,6 +2174,7 @@ def test_manual_binding(user3: UserClientFlask):
|
||||||
@pytest.mark.mvp
|
@pytest.mark.mvp
|
||||||
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||||
def test_edit_and_binding(user3: UserClientFlask):
|
def test_edit_and_binding(user3: UserClientFlask):
|
||||||
|
# TODO
|
||||||
uri = '/inventory/device/add/'
|
uri = '/inventory/device/add/'
|
||||||
user3.get(uri)
|
user3.get(uri)
|
||||||
|
|
||||||
|
|
Reference in New Issue