fix(module_2_filter):improve location filter and ordering nearest event
This commit is contained in:
@@ -1022,14 +1022,14 @@ class EventListView(generics.ListAPIView):
|
|||||||
# Sort by nearest location if latitude and longitude are provided
|
# Sort by nearest location if latitude and longitude are provided
|
||||||
latitude = self.request.query_params.get("latitude")
|
latitude = self.request.query_params.get("latitude")
|
||||||
longitude = self.request.query_params.get("longitude")
|
longitude = self.request.query_params.get("longitude")
|
||||||
|
ordering = self.request.query_params.get("ordering", "")
|
||||||
|
|
||||||
if latitude and longitude:
|
if latitude and longitude and "nearest" in ordering:
|
||||||
print("latitude fucntion called")
|
print("latitude fucntion called")
|
||||||
gmaps_service = GoogleMapsservice()
|
gmaps_service = GoogleMapsservice()
|
||||||
queryset = gmaps_service.get_nearest_events(queryset, float(latitude), float(longitude))
|
queryset = gmaps_service.get_nearest_events(queryset, float(latitude), float(longitude))
|
||||||
|
|
||||||
# Apply popularity annotation and ordering if requested
|
# Apply popularity annotation and ordering if requested
|
||||||
ordering = self.request.query_params.get("ordering")
|
|
||||||
if ordering:
|
if ordering:
|
||||||
queryset = self.apply_popularity_latest(queryset, ordering)
|
queryset = self.apply_popularity_latest(queryset, ordering)
|
||||||
return queryset
|
return queryset
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ django-cors-headers==4.3.1
|
|||||||
django-debug-toolbar==4.3.0
|
django-debug-toolbar==4.3.0
|
||||||
django-environ==0.11.2
|
django-environ==0.11.2
|
||||||
django-extensions==3.2.3
|
django-extensions==3.2.3
|
||||||
|
django-filter==24.2
|
||||||
django-phonenumber-field==7.3.0
|
django-phonenumber-field==7.3.0
|
||||||
django-quill-editor==0.1.40
|
django-quill-editor==0.1.40
|
||||||
django-taggit==5.0.1
|
django-taggit==5.0.1
|
||||||
@@ -69,7 +70,7 @@ sqlparse==0.4.4
|
|||||||
stripe==8.2.0
|
stripe==8.2.0
|
||||||
tqdm==4.66.2
|
tqdm==4.66.2
|
||||||
Twisted==23.10.0
|
Twisted==23.10.0
|
||||||
twisted-iocpsupport==1.0.4
|
# twisted-iocpsupport==1.0.4
|
||||||
txaio==23.1.1
|
txaio==23.1.1
|
||||||
typing_extensions==4.9.0
|
typing_extensions==4.9.0
|
||||||
tzdata==2024.1
|
tzdata==2024.1
|
||||||
|
|||||||
Reference in New Issue
Block a user