Skip to content

Commit

Permalink
🐛 [BUG] Fix missing Ratings returned in APIv2 (refs #3569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chatewgne committed Mar 1, 2024
1 parent 9400067 commit 5f4f379
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions geotrek/api/v2/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,13 @@ def filter_queryset(self, request, qs, view):
return self.filter_queryset_related_objects_published(qs, request, 'courses')


class SitesAndCourseRelatedPortalFilter(RelatedObjectsPublishedNotDeletedByPortalFilter):
def filter_queryset(self, request, qs, view):
set_1 = self.filter_queryset_related_objects_published_by_portal(qs, request, 'courses')
set_2 = self.filter_queryset_related_objects_published_by_portal(qs, request, 'sites')
return (set_1 | set_2).distinct()


class RelatedPortalStructureOrReservationSystemFilter(RelatedObjectsPublishedNotDeletedByPortalFilter):
def filter_queryset(self, request, qs, view):
set_1 = self.filter_queryset_related_objects_published_not_deleted_by_portal(qs, request, 'trek')
Expand Down
2 changes: 1 addition & 1 deletion geotrek/api/v2/views/outdoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class OutdoorRatingScaleViewSet(api_viewsets.GeotrekViewSet):
class OutdoorRatingViewSet(api_viewsets.GeotrekViewSet):
filter_backends = api_viewsets.GeotrekViewSet.filter_backends + (
api_filters.GeotrekRatingFilter,
api_filters.SiteRelatedPortalFilter,
api_filters.SitesAndCourseRelatedPortalFilter,
)
serializer_class = api_serializers.OutdoorRatingSerializer
queryset = outdoor_models.Rating.objects \
Expand Down

0 comments on commit 5f4f379

Please sign in to comment.