fix test 2

This commit is contained in:
Cayo Puigdefabregas 2023-01-26 11:35:08 +01:00
parent de9b525737
commit 6c9334fa76
3 changed files with 23 additions and 2 deletions

View File

@ -44,6 +44,7 @@ from ereuse_devicehub.resources.action.views.snapshot import (
from ereuse_devicehub.resources.device.models import (
SAI,
Cellphone,
Computer,
ComputerMonitor,
Desktop,
Device,
@ -332,7 +333,7 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm):
self.result[filename] = 'Error'
continue
import pdb; pdb.set_trace()
if isinstance(response.device, Computer):
response.device.user_trusts = user_trusts
db.session.add(response)
devices.append(response.device.binding.device)

View File

@ -756,6 +756,24 @@ class Device(Thing):
return ""
def get_exist_untrusted_device(self):
if isinstance(self, Computer):
if not self.system_uuid:
return True
return (
Computer.query.filter_by(
hid=self.hid,
user_trusts=False,
owner_id=g.user.id,
active=True,
placeholder=None,
).first()
or False
)
return False
def get_from_db(self):
if 'property_hid' in app.blueprints.keys():
try:

View File

@ -171,6 +171,8 @@ class Sync:
if not db_device or create_new_device:
device.tags.clear() # We don't want to add the transient dummy tags
if create_new_device or device.get_exist_untrusted_device():
device.user_trusts = False
db.session.add(device)
db_device = device
try: