22 lines
No EOL
741 B
Python
22 lines
No EOL
741 B
Python
from rest_framework import viewsets
|
|
from right_tree.api.models import Plant
|
|
from right_tree.api.serializers import PlantSerializer
|
|
from .filters import coordinate_filter, soil_variant_filter
|
|
|
|
class PlantViewSet(viewsets.ModelViewSet):
|
|
"""
|
|
Filtered viewset for plants.
|
|
"""
|
|
queryset = Plant.objects.all()
|
|
serializer_class = PlantSerializer
|
|
|
|
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)
|
|
queryset = soil_variant_filter(self.request, queryset)
|
|
|
|
return queryset
|
|
|