find route limit slice
This commit is contained in:
SDE
2023-08-29 13:31:00 +03:00
parent de0446c799
commit c8c0f43d4d
2 changed files with 20 additions and 2 deletions

View File

@@ -15,6 +15,9 @@ def get_routes_Dict(user=None, data=None):
'owner': user
})
from_el = None
to_el = None
if data:
for key, val in data.items():
if val:
@@ -25,11 +28,23 @@ def get_routes_Dict(user=None, data=None):
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',
'from_address_point_txt', 'to_address_point_txt', 'csrfmiddlewaretoken', 'sort', 'weight',
'from_el', 'to_el'
):
kwargs.update({key: val})
if key == 'from_el':
from_el = int(val)
if key == 'to_el':
to_el = int(val)
routes = Route.objects.filter(**kwargs).order_by('-modifiedDT')
if from_el and to_el:
routes = routes[from_el:to_el]
elif from_el:
routes = routes[from_el:]
elif to_el:
routes = routes[:to_el]
res_Dict = {}