Skip to content

Commit

Permalink
Attachment Viewset | Apply filtering in queryset attribute
Browse files Browse the repository at this point in the history
Remove filter_queryset method
  • Loading branch information
FrankApiyo committed Oct 23, 2024
1 parent 8f1cea4 commit 4676786
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 1 addition & 7 deletions onadata/apps/api/viewsets/dataview_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class DataViewViewSet(
A simple ViewSet for viewing and editing DataViews.
"""

queryset = DataView.objects.select_related()
queryset = DataView.objects.filter(deleted_at__isnull=True).select_related()
serializer_class = DataViewSerializer
permission_classes = [DataViewViewsetPermissions]
lookup_field = "pk"
Expand Down Expand Up @@ -155,12 +155,6 @@ def get_serializer_class(self):

return serializer_class

def filter_queryset(self, queryset):
"""
Remove deleted DataViews
"""
return super().filter_queryset(queryset.filter(deleted_at=None))

def list(self, request, *args, **kwargs):
"""
List endpoint for Filtered datasets
Expand Down
6 changes: 3 additions & 3 deletions onadata/libs/tests/serializers/test_dataview_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def get_has_hxl_support_value(data_view_name):

return data.get('has_hxl_support')

self.assertFalse(get_has_hxl_support_value("name_only"))
self.assertTrue(get_has_hxl_support_value("age_only"))
self.assertTrue(get_has_hxl_support_value("age_and_name"))
self.assertFalse(get_has_hxl_support_value('name_only'))
self.assertTrue(get_has_hxl_support_value('age_only'))
self.assertTrue(get_has_hxl_support_value('age_and_name'))

def test_name_and_xform_are_unique(self):
"""
Expand Down

0 comments on commit 4676786

Please sign in to comment.