fix new hid in build

This commit is contained in:
Cayo Puigdefabregas 2022-12-05 17:33:22 +01:00
parent 4b13995b4f
commit d6bee33601
3 changed files with 10 additions and 4 deletions

View File

@ -318,8 +318,6 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm):
try:
snapshot_json = schema.load(snapshot_json)
response = self.build(snapshot_json)
response.device.set_hid()
response.device.binding.device.set_hid()
except ValidationError as err:
txt = "{}".format(err)
self.errors(txt=txt)

View File

@ -8,6 +8,7 @@ from uuid import UUID
from flask import current_app as app
from flask import g
from marshmallow import ValidationError
from sqlalchemy.util import OrderedSet
from ereuse_devicehub.db import db
@ -115,6 +116,13 @@ class SnapshotMixin:
self.is_server_erase(snapshot)
snapshot.device.set_hid()
snapshot.device.binding.device.set_hid()
if not snapshot.device.hid:
txt = "Not exist the basic fields for to do an device. "
txt += "Please do one placeholder instead of one snapshot"
raise ValidationError(txt)
return snapshot
def is_server_erase(self, snapshot):
@ -219,8 +227,6 @@ class SnapshotView(SnapshotMixin):
try:
self.snapshot_json = resource_def.schema.load(snapshot_json)
snapshot = self.build()
snapshot.device.set_hid()
snapshot.device.binding.device.set_hid()
except Exception as err:
txt = "{}".format(err)
self.errors(txt=txt, commit=True)

View File

@ -772,6 +772,8 @@ class Device(Thing):
system_uuid = ''
if hasattr(self, 'system_uuid'):
system_uuid = str(self.system_uuid or '')
if not system_uuid or not self.manufacturer:
return ''
board = None
board_serial_number = ''