drop filter only by wb device

This commit is contained in:
Cayo Puigdefabregas 2022-07-20 10:03:46 +02:00
parent e2870f2b3e
commit a2b9d1c96d

View file

@ -111,7 +111,7 @@ class DeviceView(View):
def patch(self, id): def patch(self, id):
dev = Device.query.filter_by( dev = Device.query.filter_by(
id=id, owner_id=g.user.id, active=True, placeholder=None id=id, owner_id=g.user.id, active=True
).one() ).one()
if isinstance(dev, Computer): if isinstance(dev, Computer):
resource_def = app.resources['Computer'] resource_def = app.resources['Computer']
@ -139,14 +139,14 @@ class DeviceView(View):
def one_public(self, id: int): def one_public(self, id: int):
device = Device.query.filter_by( device = Device.query.filter_by(
devicehub_id=id, active=True, placeholder=None devicehub_id=id, active=True
).one() ).one()
return render_template('devices/layout.html', device=device, states=states) return render_template('devices/layout.html', device=device, states=states)
@auth.Auth.requires_auth @auth.Auth.requires_auth
def one_private(self, id: str): def one_private(self, id: str):
device = Device.query.filter_by( device = Device.query.filter_by(
devicehub_id=id, owner_id=g.user.id, active=True, placeholder=None devicehub_id=id, owner_id=g.user.id, active=True
).first() ).first()
if not device: if not device:
return self.one_public(id) return self.one_public(id)
@ -176,7 +176,7 @@ class DeviceView(View):
trades_dev_ids = {d.id for t in trades for d in t.devices} trades_dev_ids = {d.id for t in trades for d in t.devices}
query = ( query = (
Device.query.filter(Device.active == True, Device.placeholder == None) Device.query.filter(Device.active == True)
.filter((Device.owner_id == g.user.id) | (Device.id.in_(trades_dev_ids))) .filter((Device.owner_id == g.user.id) | (Device.id.in_(trades_dev_ids)))
.distinct() .distinct()
) )