change uuid in views and forms for system_uuid
This commit is contained in:
parent
0f916e5964
commit
34def901cb
|
@ -271,7 +271,7 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm):
|
|||
self.version = snapshot_json.get('version')
|
||||
system_uuid = self.get_uuid(debug)
|
||||
if system_uuid:
|
||||
snapshot_json['device']['uuid'] = system_uuid
|
||||
snapshot_json['device']['system_uuid'] = system_uuid
|
||||
|
||||
try:
|
||||
snapshot_json = schema.load(snapshot_json)
|
||||
|
|
|
@ -52,7 +52,7 @@ class ParseSnapshot:
|
|||
self.device['type'] = self.get_type()
|
||||
self.device['sku'] = self.get_sku()
|
||||
self.device['version'] = self.get_version()
|
||||
self.device['uuid'] = self.get_uuid()
|
||||
self.device['system_uuid'] = self.get_uuid()
|
||||
|
||||
def set_components(self):
|
||||
self.get_cpu()
|
||||
|
@ -379,7 +379,7 @@ class ParseSnapshotLsHw:
|
|||
raise ValidationError(txt)
|
||||
|
||||
self.device = pc
|
||||
self.device['uuid'] = self.get_uuid()
|
||||
self.device['system_uuid'] = self.get_uuid()
|
||||
|
||||
def set_components(self):
|
||||
memory = None
|
||||
|
|
|
@ -169,7 +169,7 @@ class SnapshotView(SnapshotMixin):
|
|||
self.sid = None
|
||||
system_uuid = self.get_uuid(snapshot_json.pop('debug', None))
|
||||
if system_uuid:
|
||||
snapshot_json['device']['uuid'] = system_uuid
|
||||
snapshot_json['device']['system_uuid'] = system_uuid
|
||||
|
||||
try:
|
||||
self.snapshot_json = resource_def.schema.load(snapshot_json)
|
||||
|
|
|
@ -177,12 +177,15 @@ class Sync:
|
|||
inspect(tag).transient for tag in device.tags
|
||||
), 'Tags cannot be synced from DB'
|
||||
db_device = None
|
||||
if isinstance(db_device, Computer):
|
||||
if db_device.uuid:
|
||||
if isinstance(device, Computer):
|
||||
# first search by uuid
|
||||
if device.system_uuid:
|
||||
with suppress(ResourceNotFound):
|
||||
db_device = Computer.query.filter_by(
|
||||
uuid=device.uuid, owner_id=g.user.id, active=True
|
||||
system_uuid=device.system_uuid, owner_id=g.user.id, active=True
|
||||
).one()
|
||||
elif device.hid:
|
||||
# if no there are any Computer by uuid search by hid
|
||||
if not db_device and device.hid:
|
||||
with suppress(ResourceNotFound):
|
||||
db_device = Device.query.filter_by(
|
||||
hid=device.hid, owner_id=g.user.id, active=True
|
||||
|
|
Reference in New Issue