edit appearance and functionality in placeholder

This commit is contained in:
Cayo Puigdefabregas 2023-06-19 11:31:40 +02:00
parent ffaff20025
commit ae310ece6d
1 changed files with 23 additions and 11 deletions

View File

@ -41,7 +41,7 @@ from ereuse_devicehub.inventory.models import (
from ereuse_devicehub.parser.models import PlaceholdersLog, SnapshotsLog from ereuse_devicehub.parser.models import PlaceholdersLog, SnapshotsLog
from ereuse_devicehub.parser.parser import ParseSnapshotLsHw from ereuse_devicehub.parser.parser import ParseSnapshotLsHw
from ereuse_devicehub.parser.schemas import Snapshot_lite from ereuse_devicehub.parser.schemas import Snapshot_lite
from ereuse_devicehub.resources.action.models import Snapshot, Trade from ereuse_devicehub.resources.action.models import Snapshot, Trade, VisualTest
from ereuse_devicehub.resources.action.schemas import Snapshot as SnapshotSchema from ereuse_devicehub.resources.action.schemas import Snapshot as SnapshotSchema
from ereuse_devicehub.resources.action.views.snapshot import ( from ereuse_devicehub.resources.action.views.snapshot import (
SnapshotMixin, SnapshotMixin,
@ -480,6 +480,10 @@ class NewDeviceForm(FlaskForm):
if self._obj.type in ['HardDrive', 'SolidStateDrive']: if self._obj.type in ['HardDrive', 'SolidStateDrive']:
if self._obj.size: if self._obj.size:
self.data_storage_size.data = self._obj.size / 1000 self.data_storage_size.data = self._obj.size / 1000
if self._obj.appearance():
self.appearance.data = self._obj.appearance().name
if self._obj.functionality():
self.functionality.data = self._obj.functionality().name
if self._obj.placeholder.is_abstract: if self._obj.placeholder.is_abstract:
self.type.render_kw = disabled self.type.render_kw = disabled
@ -698,6 +702,14 @@ class NewDeviceForm(FlaskForm):
if self.data_storage_size.data: if self.data_storage_size.data:
self._obj.size = self.data_storage_size.data * 1000 self._obj.size = self.data_storage_size.data * 1000
if not self._obj.appearance() or not self._obj.functionality():
visual_test = VisualTest(
appearance_range=self.appearance.data,
functionality_range=self.functionality.data,
device=self._obj,
)
db.session.add(visual_test)
else:
if ( if (
self.appearance.data self.appearance.data
and self.appearance.data != self._obj.appearance().name and self.appearance.data != self._obj.appearance().name