This commit is contained in:
parent
850278c297
commit
de9b525737
|
@ -297,7 +297,7 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm):
|
||||||
|
|
||||||
return is_lite
|
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()]):
|
if any([x == 'Error' for x in self.result.values()]):
|
||||||
return
|
return
|
||||||
schema = SnapshotSchema()
|
schema = SnapshotSchema()
|
||||||
|
@ -332,6 +332,8 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm):
|
||||||
self.result[filename] = 'Error'
|
self.result[filename] = 'Error'
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
import pdb; pdb.set_trace()
|
||||||
|
response.device.user_trusts = user_trusts
|
||||||
db.session.add(response)
|
db.session.add(response)
|
||||||
devices.append(response.device.binding.device)
|
devices.append(response.device.binding.device)
|
||||||
|
|
||||||
|
|
|
@ -898,7 +898,7 @@ class Device(Thing):
|
||||||
if not snapshot1:
|
if not snapshot1:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.create_new_device(snapshots.values())
|
self.create_new_device(snapshots.values(), user_trusts=self.user_trusts)
|
||||||
self.remove_snapshot(snapshots.keys())
|
self.remove_snapshot(snapshots.keys())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -915,7 +915,7 @@ class Device(Thing):
|
||||||
snapshot = file_snapshot.read()
|
snapshot = file_snapshot.read()
|
||||||
return json.loads(snapshot)
|
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
|
from ereuse_devicehub.inventory.forms import UploadSnapshotForm
|
||||||
|
|
||||||
new_snapshots = []
|
new_snapshots = []
|
||||||
|
@ -928,7 +928,7 @@ class Device(Thing):
|
||||||
form.result = {}
|
form.result = {}
|
||||||
form.snapshots = new_snapshots
|
form.snapshots = new_snapshots
|
||||||
form.create_new_devices = True
|
form.create_new_devices = True
|
||||||
form.save(commit=False)
|
form.save(commit=False, user_trusts=user_trusts)
|
||||||
|
|
||||||
def remove_snapshot(self, snapshots):
|
def remove_snapshot(self, snapshots):
|
||||||
from ereuse_devicehub.parser.models import SnapshotsLog
|
from ereuse_devicehub.parser.models import SnapshotsLog
|
||||||
|
|
Reference in New Issue