-
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.
Co-authored-by: _Kevin_Zhang_ <[email protected]>
- Loading branch information
1 parent
bfe4204
commit 7327bfe
Showing
8 changed files
with
106 additions
and
42 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
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
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,31 @@ | ||
from .models import Brand, Equipment, Supplier, Trailer, Type, UnitImage, Vehicle | ||
|
||
|
||
def infinite_filter(request): | ||
url_parameter = request.GET.get("search") | ||
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): | ||
offset = request.GET.get("o") | ||
limit = request.GET.get("l") | ||
if offset: | ||
return Vehicle.objects.all().count() > (int(offset) + int(limit)) | ||
|
||
elif limit: | ||
return Vehicle.objects.all().count() > int(limit) | ||
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
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from django.contrib import admin | ||
from django.urls import include, path | ||
|
||
from .views import VehicleDetailApiView, VehicleListApiView | ||
from .views import VehicleDetailApiView, VehicleListApiView, VehicleFilterList | ||
|
||
urlpatterns = [ | ||
path("", VehicleListApiView.as_view(), name="vehicle"), | ||
path("filter/", VehicleFilterList.as_view(), name="vehicle-list"), | ||
path("<uuid:vehicle_id>/", VehicleDetailApiView.as_view(), name="vehicle_detail"), | ||
] |
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