From de9b525737c76eb0802d7fca63ecc0f203c6f382 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 26 Jan 2023 10:46:34 +0100 Subject: [PATCH] . --- ereuse_devicehub/inventory/forms.py | 4 +++- ereuse_devicehub/resources/device/models.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 1e641f32..1910c3e8 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -297,7 +297,7 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm): return is_lite - def save(self, commit=True): + def save(self, commit=True, user_trusts=True): if any([x == 'Error' for x in self.result.values()]): return schema = SnapshotSchema() @@ -332,6 +332,8 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm): self.result[filename] = 'Error' continue + import pdb; pdb.set_trace() + response.device.user_trusts = user_trusts db.session.add(response) devices.append(response.device.binding.device) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 378613df..da129b55 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -898,7 +898,7 @@ class Device(Thing): if not snapshot1: return - self.create_new_device(snapshots.values()) + self.create_new_device(snapshots.values(), user_trusts=self.user_trusts) self.remove_snapshot(snapshots.keys()) return @@ -915,7 +915,7 @@ class Device(Thing): snapshot = file_snapshot.read() return json.loads(snapshot) - def create_new_device(self, snapshots): + def create_new_device(self, snapshots, user_trusts=True): from ereuse_devicehub.inventory.forms import UploadSnapshotForm new_snapshots = [] @@ -928,7 +928,7 @@ class Device(Thing): form.result = {} form.snapshots = new_snapshots form.create_new_devices = True - form.save(commit=False) + form.save(commit=False, user_trusts=user_trusts) def remove_snapshot(self, snapshots): from ereuse_devicehub.parser.models import SnapshotsLog