Skip to content

Commit

Permalink
feat: add stubs for observed taxa views & serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
mihow committed Aug 23, 2024
1 parent 31ceb7d commit 2e37933
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
19 changes: 19 additions & 0 deletions ami/taxa/serializers.py
Original file line number Diff line number Diff line change
@@ -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",
]
17 changes: 16 additions & 1 deletion ami/taxa/views.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions config/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 2e37933

Please sign in to comment.