-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c0d94d
commit 66d8add
Showing
3 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from .models import ( | ||
Brand, Equipment, Supplier, Trailer, Type, UnitImage, Vehicle) | ||
|
||
def infinite_filter(request): | ||
url_parameter = request.GET.get('p') | ||
if url_parameter: | ||
limit = request.GET.get('l') | ||
offset = request.GET.get('o') | ||
if limit and offset: | ||
return Vehicle.objects.filter(unicode_id__icontains=url_parameter)[:int(offset) + int(limit)] | ||
elif limit: | ||
return Vehicle.objects.filter(unicode_id__icontains=url_parameter)[:int(limit)] | ||
else: | ||
return Vehicle.objects.filter(unicode_id__icontains=url_parameter)[:15] | ||
return Vehicle.objects.all()[:40] | ||
|
||
def has_more_data(request): | ||
o = request.GET.get('o') | ||
l = request.GET.get('l') | ||
if o: | ||
return Vehicle.objects.all().count() > int(o) | ||
|
||
elif l: | ||
return Vehicle.objects.all().count() > int(l) | ||
else: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters