diff --git a/ami/taxa/serializers.py b/ami/taxa/serializers.py new file mode 100644 index 000000000..6f091ab23 --- /dev/null +++ b/ami/taxa/serializers.py @@ -0,0 +1,19 @@ +from ami.base.serializers import DefaultSerializer +from ami.taxa.models import TaxonObserved + + +class TaxonObservedSerializer(DefaultSerializer): + class Meta: + model = TaxonObserved + fields = [ + "id", + "taxon", + "project", + "detections_count", + "occurrences_count", + "best_detection", + "best_determination_score", + "last_detected", + "created_at", + "updated_at", + ] diff --git a/ami/taxa/views.py b/ami/taxa/views.py index 60f00ef0e..fde81a2d6 100644 --- a/ami/taxa/views.py +++ b/ami/taxa/views.py @@ -1 +1,16 @@ -# Create your views here. +import logging + +from ami.main.api.views import DefaultViewSet +from ami.taxa.models import TaxonObserved +from ami.taxa.serializers import TaxonObservedSerializer + +logger = logging.getLogger(__name__) + + +class TaxonObservedViewSet(DefaultViewSet): + """ + Endpoint for taxa information that have been observed in a project. + """ + + queryset = TaxonObserved.objects.all() + serializer_class = TaxonObservedSerializer diff --git a/config/api_router.py b/config/api_router.py index 8950a3820..239f354c7 100644 --- a/config/api_router.py +++ b/config/api_router.py @@ -8,6 +8,7 @@ from ami.labelstudio import views as labelstudio_views from ami.main.api import views from ami.ml import views as ml_views +from ami.taxa import views as taxa_views if settings.DEBUG: router = DefaultRouter() @@ -26,6 +27,7 @@ router.register(r"captures", views.SourceImageViewSet) router.register(r"detections", views.DetectionViewSet) router.register(r"occurrences", views.OccurrenceViewSet) +router.register(r"taxa/observed", taxa_views.TaxonObservedViewSet) router.register(r"taxa", views.TaxonViewSet) router.register(r"ml/algorithms", ml_views.AlgorithmViewSet) router.register(r"ml/pipelines", ml_views.PipelineViewSet)