diff --git a/mvj/urls.py b/mvj/urls.py index 9c17eaf1..c0d3a594 100755 --- a/mvj/urls.py +++ b/mvj/urls.py @@ -123,6 +123,7 @@ PlotSearchSubtypeViewSet, PlotSearchTargetViewSet, PlotSearchTypeViewSet, + PlotSearchUIDataView, PlotSearchViewSet, TargetStatusGeneratePDF, ) @@ -259,6 +260,9 @@ name="target_status-pdf", ), path("area_search_pdf/", AreaSearchGeneratePDF.as_view(), name="area-search-pdf"), + path( + "pub/plot_search_ui/", PlotSearchUIDataView.as_view(), name="pub_plot_search_ui" + ), path("auditlog/", AuditLogView.as_view(), name="auditlog"), path("contact_exists/", ContactExistsView.as_view(), name="contact-exists"), path( diff --git a/plotsearch/views/plot_search.py b/plotsearch/views/plot_search.py index e5442a04..0024f481 100755 --- a/plotsearch/views/plot_search.py +++ b/plotsearch/views/plot_search.py @@ -13,7 +13,7 @@ from rest_framework import mixins, viewsets from rest_framework.decorators import action from rest_framework.filters import OrderingFilter -from rest_framework.permissions import IsAuthenticated +from rest_framework.permissions import AllowAny, IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView from rest_framework_gis.filters import InBBoxFilter @@ -159,6 +159,22 @@ def get_answers_xlsx(self, *args, **kwargs): return response +class PlotSearchUIDataView(APIView): + permission_classes = (AllowAny,) + + def get(self, request): + aggregated_data = { + "plot_search": PlotSearch.objects.filter( + search_class="plot_search" + ).count(), + "other_search": PlotSearch.objects.filter( + search_class="other_search" + ).count(), + } + + return Response(aggregated_data) + + class PlotSearchTargetViewSet(mixins.UpdateModelMixin, viewsets.GenericViewSet): queryset = PlotSearchTarget.objects.all() serializer_class = PlotSearchTargetSerializer