Adds display size to mobile device schema
This commit is contained in:
parent
024a9a7d24
commit
dc8aea9b9b
|
@ -318,7 +318,7 @@ class Snapshot(ActionWithOneDevice):
|
||||||
|
|
||||||
@validates_schema
|
@validates_schema
|
||||||
def validate_components_only_workbench(self, data: dict):
|
def validate_components_only_workbench(self, data: dict):
|
||||||
if data['software'] != SnapshotSoftware.Workbench:
|
if (data['software'] != SnapshotSoftware.Workbench) and (data['software'] != SnapshotSoftware.WorkbenchAndroid):
|
||||||
if data.get('components', None) is not None:
|
if data.get('components', None) is not None:
|
||||||
raise ValidationError('Only Workbench can add component info',
|
raise ValidationError('Only Workbench can add component info',
|
||||||
field_names=['components'])
|
field_names=['components'])
|
||||||
|
@ -329,14 +329,18 @@ class Snapshot(ActionWithOneDevice):
|
||||||
# todo test
|
# todo test
|
||||||
if data['software'] == SnapshotSoftware.Workbench:
|
if data['software'] == SnapshotSoftware.Workbench:
|
||||||
if not data.get('uuid', None):
|
if not data.get('uuid', None):
|
||||||
raise ValidationError('Snapshots from Workbench must have uuid',
|
raise ValidationError('Snapshots from Workbench and WorkbenchAndroid must have uuid',
|
||||||
field_names=['uuid'])
|
field_names=['uuid'])
|
||||||
if data.get('elapsed', None) is None:
|
if data.get('elapsed', None) is None:
|
||||||
raise ValidationError('Snapshots from Workbench must have elapsed',
|
raise ValidationError('Snapshots from Workbench must have elapsed',
|
||||||
field_names=['elapsed'])
|
field_names=['elapsed'])
|
||||||
|
elif data['software'] == SnapshotSoftware.WorkbenchAndroid:
|
||||||
|
if not data.get('uuid', None):
|
||||||
|
raise ValidationError('Snapshots from Workbench and WorkbenchAndroid must have uuid',
|
||||||
|
field_names=['uuid'])
|
||||||
else:
|
else:
|
||||||
if data.get('uuid', None):
|
if data.get('uuid', None):
|
||||||
raise ValidationError('Only Snapshots from Workbench can have uuid',
|
raise ValidationError('Only Snapshots from Workbench or WorkbenchAndroid can have uuid',
|
||||||
field_names=['uuid'])
|
field_names=['uuid'])
|
||||||
if data.get('elapsed', None):
|
if data.get('elapsed', None):
|
||||||
raise ValidationError('Only Snapshots from Workbench can have elapsed',
|
raise ValidationError('Only Snapshots from Workbench can have elapsed',
|
||||||
|
|
|
@ -55,8 +55,8 @@ class ActionView(View):
|
||||||
# snapshot, and we want to wait to flush snapshot at the end
|
# snapshot, and we want to wait to flush snapshot at the end
|
||||||
device = snapshot_json.pop('device') # type: Computer
|
device = snapshot_json.pop('device') # type: Computer
|
||||||
components = None
|
components = None
|
||||||
if snapshot_json['software'] == SnapshotSoftware.Workbench:
|
if snapshot_json['software'] == (SnapshotSoftware.Workbench or SnapshotSoftware.WorkbenchAndroid):
|
||||||
components = snapshot_json.pop('components') # type: List[Component]
|
components = snapshot_json.pop('components', None) # type: List[Component]
|
||||||
snapshot = Snapshot(**snapshot_json)
|
snapshot = Snapshot(**snapshot_json)
|
||||||
|
|
||||||
# Remove new actions from devices so they don't interfere with sync
|
# Remove new actions from devices so they don't interfere with sync
|
||||||
|
@ -94,6 +94,8 @@ class ActionView(View):
|
||||||
snapshot.actions.add(rate_computer)
|
snapshot.actions.add(rate_computer)
|
||||||
if price:
|
if price:
|
||||||
snapshot.actions.add(price)
|
snapshot.actions.add(price)
|
||||||
|
elif snapshot.software == SnapshotSoftware.WorkbenchAndroid:
|
||||||
|
pass # TODO try except to compute RateMobile
|
||||||
|
|
||||||
db.session.add(snapshot)
|
db.session.add(snapshot)
|
||||||
db.session().final_flush()
|
db.session().final_flush()
|
||||||
|
|
|
@ -512,6 +512,8 @@ class Mobile(Device):
|
||||||
ram_size.comment = """The total of RAM of the device in MB."""
|
ram_size.comment = """The total of RAM of the device in MB."""
|
||||||
data_storage_size = db.Column(db.Integer, check_range('data_storage_size', 0, 10 ** 8))
|
data_storage_size = db.Column(db.Integer, check_range('data_storage_size', 0, 10 ** 8))
|
||||||
data_storage_size.comment = """The total of data storage of the device in MB"""
|
data_storage_size.comment = """The total of data storage of the device in MB"""
|
||||||
|
display_size = db.Column(db.Float(decimal_return_scale=1), check_range('display_size', min=0.1, max=30.0))
|
||||||
|
display_size.comment = """The total size of the device screen"""
|
||||||
|
|
||||||
@validates('imei')
|
@validates('imei')
|
||||||
def validate_imei(self, _, value: int):
|
def validate_imei(self, _, value: int):
|
||||||
|
|
|
@ -219,6 +219,7 @@ class Mobile(Device):
|
||||||
meid = ... # type: Column
|
meid = ... # type: Column
|
||||||
ram_size = ... # type: Column
|
ram_size = ... # type: Column
|
||||||
data_storage_size = ... # type: Column
|
data_storage_size = ... # type: Column
|
||||||
|
display_size = ... # type: Column
|
||||||
|
|
||||||
def __init__(self, **kwargs) -> None:
|
def __init__(self, **kwargs) -> None:
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
@ -226,6 +227,7 @@ class Mobile(Device):
|
||||||
self.meid = ... # type: Optional[str]
|
self.meid = ... # type: Optional[str]
|
||||||
self.ram_size = ... # type: Optional[int]
|
self.ram_size = ... # type: Optional[int]
|
||||||
self.data_storage_size = ... # type: Optional[int]
|
self.data_storage_size = ... # type: Optional[int]
|
||||||
|
self.display_size = ... # type: Optional[float]
|
||||||
|
|
||||||
|
|
||||||
class Smartphone(Mobile):
|
class Smartphone(Mobile):
|
||||||
|
|
|
@ -197,6 +197,9 @@ class Mobile(Device):
|
||||||
data_storage_size = Integer(validate=Range(0, 10 ** 8),
|
data_storage_size = Integer(validate=Range(0, 10 ** 8),
|
||||||
data_key='dataStorageSize',
|
data_key='dataStorageSize',
|
||||||
description=m.Mobile.data_storage_size)
|
description=m.Mobile.data_storage_size)
|
||||||
|
display_size = Float(validate=Range(min=0.1, max=30.0),
|
||||||
|
data_key='displaySize',
|
||||||
|
description=m.Mobile.display_size.comment)
|
||||||
|
|
||||||
@pre_load
|
@pre_load
|
||||||
def convert_check_imei(self, data):
|
def convert_check_imei(self, data):
|
||||||
|
|
|
@ -9,6 +9,7 @@ import inflection
|
||||||
class SnapshotSoftware(Enum):
|
class SnapshotSoftware(Enum):
|
||||||
"""The software used to perform the Snapshot."""
|
"""The software used to perform the Snapshot."""
|
||||||
Workbench = 'Workbench'
|
Workbench = 'Workbench'
|
||||||
|
WorkbenchAndroid = 'WorkbenchAndroid'
|
||||||
AndroidApp = 'AndroidApp'
|
AndroidApp = 'AndroidApp'
|
||||||
Web = 'Web'
|
Web = 'Web'
|
||||||
DesktopApp = 'DesktopApp'
|
DesktopApp = 'DesktopApp'
|
||||||
|
|
Reference in a new issue