Adds display size to mobile device schema
This commit is contained in:
parent
a93c2737f6
commit
1497f91684
|
@ -318,7 +318,7 @@ class Snapshot(ActionWithOneDevice):
|
|||
|
||||
@validates_schema
|
||||
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:
|
||||
raise ValidationError('Only Workbench can add component info',
|
||||
field_names=['components'])
|
||||
|
@ -329,14 +329,18 @@ class Snapshot(ActionWithOneDevice):
|
|||
# todo test
|
||||
if data['software'] == SnapshotSoftware.Workbench:
|
||||
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'])
|
||||
if data.get('elapsed', None) is None:
|
||||
raise ValidationError('Snapshots from Workbench must have 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:
|
||||
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'])
|
||||
if data.get('elapsed', None):
|
||||
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
|
||||
device = snapshot_json.pop('device') # type: Computer
|
||||
components = None
|
||||
if snapshot_json['software'] == SnapshotSoftware.Workbench:
|
||||
components = snapshot_json.pop('components') # type: List[Component]
|
||||
if snapshot_json['software'] == (SnapshotSoftware.Workbench or SnapshotSoftware.WorkbenchAndroid):
|
||||
components = snapshot_json.pop('components', None) # type: List[Component]
|
||||
snapshot = Snapshot(**snapshot_json)
|
||||
|
||||
# Remove new actions from devices so they don't interfere with sync
|
||||
|
@ -94,6 +94,8 @@ class ActionView(View):
|
|||
snapshot.actions.add(rate_computer)
|
||||
if price:
|
||||
snapshot.actions.add(price)
|
||||
elif snapshot.software == SnapshotSoftware.WorkbenchAndroid:
|
||||
pass # TODO try except to compute RateMobile
|
||||
|
||||
db.session.add(snapshot)
|
||||
db.session().final_flush()
|
||||
|
|
|
@ -496,6 +496,8 @@ class Mobile(Device):
|
|||
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.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')
|
||||
def validate_imei(self, _, value: int):
|
||||
|
|
|
@ -210,6 +210,7 @@ class Mobile(Device):
|
|||
meid = ... # type: Column
|
||||
ram_size = ... # type: Column
|
||||
data_storage_size = ... # type: Column
|
||||
display_size = ... # type: Column
|
||||
|
||||
def __init__(self, **kwargs) -> None:
|
||||
super().__init__(**kwargs)
|
||||
|
@ -217,6 +218,7 @@ class Mobile(Device):
|
|||
self.meid = ... # type: Optional[str]
|
||||
self.ram_size = ... # type: Optional[int]
|
||||
self.data_storage_size = ... # type: Optional[int]
|
||||
self.display_size = ... # type: Optional[float]
|
||||
|
||||
|
||||
class Smartphone(Mobile):
|
||||
|
|
|
@ -189,6 +189,9 @@ class Mobile(Device):
|
|||
data_storage_size = Integer(validate=Range(0, 10 ** 8),
|
||||
data_key='dataStorageSize',
|
||||
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
|
||||
def convert_check_imei(self, data):
|
||||
|
|
|
@ -9,6 +9,7 @@ import inflection
|
|||
class SnapshotSoftware(Enum):
|
||||
"""The software used to perform the Snapshot."""
|
||||
Workbench = 'Workbench'
|
||||
WorkbenchAndroid = 'WorkbenchAndroid'
|
||||
AndroidApp = 'AndroidApp'
|
||||
Web = 'Web'
|
||||
DesktopApp = 'DesktopApp'
|
||||
|
|
Reference in New Issue