Skip to content

Commit

Permalink
update view function
Browse files Browse the repository at this point in the history
  • Loading branch information
MaertHaekkinen committed Oct 23, 2024
1 parent 14e2780 commit 55dee1c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ajapaik/ajapaik/opendata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from rest_framework import filters, viewsets, serializers
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.pagination import LimitOffsetPagination

from ajapaik.ajapaik.models import Photo, GeoTag
from ajapaik.ajapaik.search_indexes import PhotoIndex
Expand Down Expand Up @@ -46,6 +46,7 @@ class Meta:
model = Photo
fields = '__all__'


class CustomLimitOffsetPagination(LimitOffsetPagination):
def get_count(self, queryset):
"""
Expand All @@ -56,6 +57,7 @@ def get_count(self, queryset):
except (AttributeError, TypeError):
return len(queryset)


class PhotoViewSet(viewsets.ModelViewSet):
queryset = Photo.objects.filter(rephoto_of__isnull=True)
serializer_class = PhotoSerializer
Expand All @@ -68,8 +70,8 @@ class PhotoViewSet(viewsets.ModelViewSet):
class PhotoGeoTagViewSet(viewsets.ViewSet):
permission_classes = (AllowAny,)

def retrieve(self, request, pk=None):
queryset = GeoTag.objects.filter(photo__pk=pk)
def retrieve(self, request, photo_id):
queryset = GeoTag.objects.filter(photo__pk=photo_id)
serializer = GeoTagSerializer(queryset, many=True)

return Response(serializer.data)

0 comments on commit 55dee1c

Please sign in to comment.