Merge pull request #454 from eReuse/bugfix/4350-edit-imei
Bugfix/4350 edit imei
This commit is contained in:
commit
a38c990412
|
@ -520,10 +520,10 @@ class NewDeviceForm(FlaskForm):
|
|||
self.depth.errors = txt
|
||||
is_valid = False
|
||||
|
||||
if self.imei.data and self.amount.data == 1:
|
||||
if not 13 < len(str(self.imei.data)) < 17:
|
||||
self.imei.errors = error
|
||||
is_valid = False
|
||||
# if self.imei.data and self.amount.data == 1:
|
||||
# if not 13 < len(str(self.imei.data)) < 17:
|
||||
# self.imei.errors = error
|
||||
# is_valid = False
|
||||
|
||||
if self.meid.data and self.amount.data == 1:
|
||||
meid = self.meid.data
|
||||
|
|
|
@ -34,7 +34,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
from sqlalchemy.orm import ColumnProperty, backref, relationship, validates
|
||||
from sqlalchemy.util import OrderedSet
|
||||
from sqlalchemy_utils import ColorType
|
||||
from stdnum import imei, meid
|
||||
from stdnum import meid
|
||||
|
||||
from ereuse_devicehub.db import db
|
||||
from ereuse_devicehub.ereuse_utils.naming import HID_CONVERSION_DOC
|
||||
|
@ -1478,11 +1478,11 @@ class Mobile(Device):
|
|||
)
|
||||
display_size.comment = """The total size of the device screen"""
|
||||
|
||||
@validates('imei')
|
||||
def validate_imei(self, _, value: int):
|
||||
if value and not imei.is_valid(str(value)):
|
||||
raise ValidationError('{} is not a valid imei.'.format(value))
|
||||
return value
|
||||
# @validates('imei')
|
||||
# def validate_imei(self, _, value: int):
|
||||
# if value and not imei.is_valid(str(value)):
|
||||
# raise ValidationError('{} is not a valid imei.'.format(value))
|
||||
# return value
|
||||
|
||||
@validates('meid')
|
||||
def validate_meid(self, _, value: str):
|
||||
|
|
|
@ -16,7 +16,7 @@ from marshmallow.fields import (
|
|||
)
|
||||
from marshmallow.validate import Length, OneOf, Range
|
||||
from sqlalchemy.util import OrderedSet
|
||||
from stdnum import imei, meid
|
||||
from stdnum import meid
|
||||
|
||||
from ereuse_devicehub.marshmallow import NestedOn
|
||||
from ereuse_devicehub.resources import enums
|
||||
|
@ -304,7 +304,8 @@ class Mobile(Device):
|
|||
@pre_load
|
||||
def convert_check_imei(self, data):
|
||||
if data.get('imei', None):
|
||||
data['imei'] = int(imei.validate(data['imei']))
|
||||
# data['imei'] = int(imei.validate(data['imei']))
|
||||
data['imei'] = int(data['imei'].replace("-", ""))
|
||||
return data
|
||||
|
||||
@pre_load
|
||||
|
|
|
@ -264,6 +264,7 @@ class BaseDeviceRow(OrderedDict):
|
|||
self['Data Storage Rate'] = ''
|
||||
self['Data Storage Range'] = ''
|
||||
self['Benchmark RamSysbench (points)'] = ''
|
||||
self['IMEI'] = ''
|
||||
|
||||
|
||||
class DeviceRow(BaseDeviceRow):
|
||||
|
@ -340,6 +341,9 @@ class DeviceRow(BaseDeviceRow):
|
|||
|
||||
self.get_placeholder_datas()
|
||||
|
||||
if isinstance(device, d.Mobile):
|
||||
self['IMEI'] = device.imei or ''
|
||||
|
||||
def components(self):
|
||||
"""Function to get all components information of a device."""
|
||||
assert isinstance(self.device, d.Computer)
|
||||
|
|
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
|
@ -2239,7 +2239,6 @@ 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)
|
||||
|
||||
|
|
Reference in New Issue