This commit is contained in:
Cayo Puigdefabregas 2023-01-26 10:46:34 +01:00
parent 850278c297
commit de9b525737
2 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -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