From 188866eda163713a2380ad4b977458f1cecf882f Mon Sep 17 00:00:00 2001 From: SDE Date: Fri, 25 Aug 2023 15:31:11 +0300 Subject: [PATCH] 0.4.5 routes filter --- RoutesApp/funcs.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RoutesApp/funcs.py b/RoutesApp/funcs.py index cc82b73..d84bed2 100644 --- a/RoutesApp/funcs.py +++ b/RoutesApp/funcs.py @@ -18,7 +18,15 @@ def get_routes_Dict(user=None, data=None): if data: for key, val in data.items(): if val: - if key not in ('from_address_point_txt', 'to_address_point_txt', 'csrfmiddlewaretoken', 'sort'): + if key == 'weight': + weight_list = val.split(';') + if weight_list[0]: + kwargs.update({f'{key}__gte': int(weight_list[0])}) + if weight_list[1]: + kwargs.update({f'{key}__lte': int(weight_list[1])}) + if key not in ( + 'from_address_point_txt', 'to_address_point_txt', 'csrfmiddlewaretoken', 'sort', 'weight', + ): kwargs.update({key: val}) routes = Route.objects.filter(**kwargs).order_by('-modifiedDT')