add both device in a public page when is a twin device

This commit is contained in:
Cayo Puigdefabregas 2022-08-29 16:36:57 +02:00
parent 05d1f9698c
commit 30f511a03a
1 changed files with 5 additions and 7 deletions

View File

@ -110,9 +110,7 @@ class DeviceView(View):
return super().get(id) return super().get(id)
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).one()
id=id, owner_id=g.user.id, active=True
).one()
if isinstance(dev, Computer): if isinstance(dev, Computer):
resource_def = app.resources['Computer'] resource_def = app.resources['Computer']
# TODO check how to handle the 'actions_one' # TODO check how to handle the 'actions_one'
@ -138,13 +136,13 @@ class DeviceView(View):
return self.one_private(id) return self.one_private(id)
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).one()
devicehub_id=id, active=True
).one()
abstract = None abstract = None
if device.is_abstract() == 'Twin': if device.is_abstract() == 'Twin':
abstract = device.placeholder.binding abstract = device.placeholder.binding
return render_template('devices/layout.html', device=device, states=states, abstract=abstract) return render_template(
'devices/layout.html', device=device, states=states, abstract=abstract
)
@auth.Auth.requires_auth @auth.Auth.requires_auth
def one_private(self, id: str): def one_private(self, id: str):