only sync DataStorages
This commit is contained in:
parent
2553a9cdd0
commit
77c8e2181f
|
@ -16,19 +16,20 @@ from ereuse_devicehub.resources.action.models import Remove
|
||||||
from ereuse_devicehub.resources.device.models import (
|
from ereuse_devicehub.resources.device.models import (
|
||||||
Component,
|
Component,
|
||||||
Computer,
|
Computer,
|
||||||
|
DataStorage,
|
||||||
Device,
|
Device,
|
||||||
Placeholder,
|
Placeholder,
|
||||||
)
|
)
|
||||||
from ereuse_devicehub.resources.tag.model import Tag
|
from ereuse_devicehub.resources.tag.model import Tag
|
||||||
|
|
||||||
DEVICES_ALLOW_DUPLICITY = [
|
# DEVICES_ALLOW_DUPLICITY = [
|
||||||
'RamModule',
|
# 'RamModule',
|
||||||
'Display',
|
# 'Display',
|
||||||
'SoundCard',
|
# 'SoundCard',
|
||||||
'Battery',
|
# 'Battery',
|
||||||
'Camera',
|
# 'Camera',
|
||||||
'GraphicCard',
|
# 'GraphicCard',
|
||||||
]
|
# ]
|
||||||
|
|
||||||
|
|
||||||
class Sync:
|
class Sync:
|
||||||
|
@ -119,7 +120,7 @@ class Sync:
|
||||||
"""
|
"""
|
||||||
assert inspect(component).transient, 'Component should not be synced from DB'
|
assert inspect(component).transient, 'Component should not be synced from DB'
|
||||||
# if not is a DataStorage, then need build a new one
|
# if not is a DataStorage, then need build a new one
|
||||||
if component.t in DEVICES_ALLOW_DUPLICITY:
|
if not isinstance(component, DataStorage):
|
||||||
db.session.add(component)
|
db.session.add(component)
|
||||||
is_new = True
|
is_new = True
|
||||||
return component, is_new
|
return component, is_new
|
||||||
|
|
|
@ -2941,7 +2941,7 @@ def test_delete_devices_check_sync(user: UserClient):
|
||||||
in [y.device.id for y in x.actions if hasattr(y, 'device')]
|
in [y.device.id for y in x.actions if hasattr(y, 'device')]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
== 2
|
== 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue