Skip to content

Commit

Permalink
do not override filter_queryset on viewsets (#746)
Browse files Browse the repository at this point in the history
[#188679583]
  • Loading branch information
uraniumanchor authored Dec 12, 2024
1 parent f0de4c8 commit f32720c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tracker/api/views/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def __init__(self, country=None, *args, **kwargs):
self.country = country
super().__init__(*args, **kwargs)

def filter_queryset(self, queryset):
def get_queryset(self):
queryset = super().get_queryset()
if self.country:
queryset = queryset.filter(country=self.country)
return queryset
3 changes: 2 additions & 1 deletion tracker/api/views/donation_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def __init__(self, *args, donation=None, bid=None, **kwargs):
self.bid = bid
super().__init__(*args, **kwargs)

def filter_queryset(self, queryset):
def get_queryset(self):
queryset = super().get_queryset()
# this can be filtered in multiple ways
# - by donation, which excludes hidden children unless explicitly asked for
# - by exact bid, which includes the descendant tree if there is one, excluding
Expand Down
4 changes: 2 additions & 2 deletions tracker/api/views/milestone.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def _include_hidden(self, instance=None):
isinstance(instance, Milestone) and instance.visible
) or 'all' in self.request.query_params

def filter_queryset(self, queryset):
def get_queryset(self):
queryset = super().get_queryset()
if not (self.detail or 'all' in self.request.query_params):
queryset = queryset.filter(visible=True)
return super().filter_queryset(queryset)
return queryset

0 comments on commit f32720c

Please sign in to comment.