remove validate of imei

This commit is contained in:
Cayo Puigdefabregas 2023-06-07 12:50:21 +02:00
parent 2c171d8e26
commit 2ef6e6cb49
3 changed files with 16 additions and 12 deletions

View File

@ -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):

View File

@ -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):

View File

@ -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)