From 4935a1bd7546f876c6f10d5a30764c2ca7a1b84d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 30 Aug 2022 15:12:14 +0200 Subject: [PATCH] add phid in advanced search --- ereuse_devicehub/inventory/forms.py | 8 +++- .../templates/inventory/search.html | 43 ++++--------------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 83d18ad9..ede98e95 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -110,7 +110,13 @@ class AdvancedSearchForm(FlaskForm): self.search(dhids) def search(self, dhids): - self.devices = Device.query.filter(Device.devicehub_id.in_(dhids)) + query = Device.query.filter(Device.owner_id == g.user.id) + self.devices = query.join(Device.placeholder).filter( + or_( + Device.devicehub_id.in_(dhids), + Placeholder.phid.in_(dhids), + ) + ) class FilterForm(FlaskForm): diff --git a/ereuse_devicehub/templates/inventory/search.html b/ereuse_devicehub/templates/inventory/search.html index d996a1f3..06a4f42e 100644 --- a/ereuse_devicehub/templates/inventory/search.html +++ b/ereuse_devicehub/templates/inventory/search.html @@ -28,7 +28,7 @@ - {% if devices %} + {% if devices.count() %}
@@ -178,42 +178,11 @@
- -
-{% include "inventory/addDevicestag.html" %} {% include "inventory/lot_delete_modal.html" %} {% include "inventory/actions.html" %} {% include "inventory/allocate.html" %} {% include "inventory/data_wipe.html" %} {% include "inventory/trade.html" %} {% include "inventory/alert_export_error.html" %} -{% include "inventory/alert_unlink_tag_error.html" %} {% include "inventory/alert_lots_changes.html" %}