fixing, vanish deactivate devices

This commit is contained in:
Cayo Puigdefabregas 2021-10-05 14:33:28 +02:00
parent 9ea0a05de6
commit aa4ebeb504
2 changed files with 9 additions and 2 deletions

View File

@ -70,7 +70,6 @@ class Filters(query.Query):
# due to having multiple paths to the same
lot = query.Join((Device.id == LotDeviceDescendants.device_id),
LotQ)
active = True
class Sorting(query.Sort):
@ -159,7 +158,7 @@ class DeviceView(View):
trades_dev_ids = {d.id for t in trades for d in t.devices}
query = Device.query.filter(
query = Device.query.filter(Device.active == True).filter(
(Device.owner_id == g.user.id) | (Device.id.in_(trades_dev_ids))
).distinct()

View File

@ -2512,6 +2512,7 @@ def test_delete_devices(user: UserClient):
action, _ = user.post(res=models.Action, data=request)
# Check get one device
user.get(res=Device, item=snap['device']['devicehubID'], status=404)
db_device = Device.query.filter_by(id=snap['device']['id']).one()
@ -2520,3 +2521,10 @@ def test_delete_devices(user: UserClient):
assert action_delete.t == 'Delete'
assert str(action_delete.id) == action['id']
assert db_device.active == False
# Check use of filter from frontend
url = '/devices/?filter={"type":["Computer"]}'
devices, res = user.get(url, None)
assert len(devices['items']) == 0