Skip to content

Commit

Permalink
Publish on website only contribution validated AND attached to the re…
Browse files Browse the repository at this point in the history
…quested portal
  • Loading branch information
babastienne committed May 3, 2024
1 parent 74205af commit f75addc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions georiviere/portal/views/contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,6 @@ class CustomContributionViewSet(
mixins.ListModelMixin,
viewsets.GenericViewSet,
):
queryset = CustomContribution.objects.filter(validated=True).annotate(
geometry=Transform(F("geom"), settings.API_SRID)
).prefetch_related("attachments")
serializer_class = CustomContributionSerializer
geojson_serializer_class = CustomContributionGeoJSONSerializer
renderer_classes = (
Expand All @@ -311,6 +308,13 @@ class CustomContributionViewSet(
permission_classes = [permissions.AllowAny]
pagination_class = LimitOffsetPagination

def get_queryset(self):
portal_pk = self.kwargs["portal_pk"]
queryset = CustomContribution.objects.filter(portal_id=portal_pk, validated=True).annotate(
geometry=Transform(F("geom"), settings.API_SRID)
).prefetch_related("attachments")
return queryset

def retrieve(self, request, *args, **kwargs):
""" Customize retrieve method to add custom type values to the response"""
object = self.get_object()
Expand Down

0 comments on commit f75addc

Please sign in to comment.