diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 38dc142e..e6662f26 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -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): diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index 527c7328..dc2f8003 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -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 @@ -301,11 +301,11 @@ class Mobile(Device): description=m.Mobile.display_size.comment, ) - @pre_load - def convert_check_imei(self, data): - if data.get('imei', None): - data['imei'] = int(imei.validate(data['imei'])) - return data + # @pre_load + # def convert_check_imei(self, data): + # if data.get('imei', None): + # data['imei'] = int(imei.validate(data['imei'])) + # return data @pre_load def convert_check_meid(self, data: dict): diff --git a/ereuse_devicehub/resources/documents/device_row.py b/ereuse_devicehub/resources/documents/device_row.py index aac1f56a..edb1282f 100644 --- a/ereuse_devicehub/resources/documents/device_row.py +++ b/ereuse_devicehub/resources/documents/device_row.py @@ -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)