Filter for show only dhid tags

This commit is contained in:
Cayo Puigdefabregas 2022-03-17 18:09:08 +01:00
parent f8e1776ca8
commit 3ac3802719
1 changed files with 13 additions and 1 deletions

View File

@ -1019,6 +1019,18 @@ class PrintTagsForm(FlaskForm):
return False
device_ids = self.devices.data.split(",")
self._tags = Tag.query.filter(Tag.device_id.in_(device_ids)).all()
self._devices = (
Device.query.filter(Device.id.in_(device_ids))
.filter(Device.owner_id == g.user.id)
.distinct()
.all()
)
dhids = [x.devicehub_id for x in self._devices]
# filter for found all tags of a list of devices
# self._tags = Tag.query.filter(Tag.owner_id == g.user.id).filter(Tag.device_id.in_(dhids)).all()
# filter for found all tags equal to devicehub_id
self._tags = (
Tag.query.filter(Tag.owner_id == g.user.id).filter(Tag.id.in_(dhids)).all()
)
return is_valid