2021-10-07 08:59:57 +13:00
|
|
|
from rest_framework import viewsets
|
|
|
|
from right_tree.api.models import Plant
|
|
|
|
from right_tree.api.serializers import PlantSerializer
|
2021-10-19 16:06:21 +13:00
|
|
|
from .filters import coordinate_filter
|
2021-10-07 08:59:57 +13:00
|
|
|
|
|
|
|
class PlantViewSet(viewsets.ModelViewSet):
|
|
|
|
"""
|
|
|
|
API endpoint that allows hours to be grouped or edited.
|
|
|
|
"""
|
|
|
|
queryset = Plant.objects.all()
|
|
|
|
serializer_class = PlantSerializer
|
2021-10-19 16:06:21 +13:00
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
""" Filtering plant query set by query parameters in the URL.
|
|
|
|
(May want to eventually use django filters to break up the logic...)
|
|
|
|
"""
|
|
|
|
queryset = Plant.objects.all()
|
|
|
|
queryset = coordinate_filter(self.request, queryset)
|
|
|
|
|
|
|
|
return queryset
|
|
|
|
|