From ea66c31a079cbaaf3ea43c8055bfe3f3028c06f5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 8 Mar 2022 10:30:53 +0100 Subject: [PATCH] fix bug --- ereuse_devicehub/inventory/forms.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 91b80305..fae58678 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -98,14 +98,22 @@ class FilterForm(FlaskForm): filter = SelectField('', choices=DEVICES, default="Computer", render_kw={'class': "form-select"}) - def search(self): - device = dict(DEVICES).get(request.args.get('filter')) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.device = dict(DEVICES).get(request.args.get('filter')) + if self.device: + self.filter.data = self.device - if device == "Computer": + def search(self): + + if self.device == "Computer": return ['Desktop', 'Laptop', 'Server'] - if device: - return [device] + if self.device == "DataStorage": + return ['HardDrive', 'SolidStateDrive'] + + if self.device: + return [self.device] return ['Desktop', 'Laptop', 'Server']