Skip to content

Commit

Permalink
we finally got there with the qs filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiebelle committed Jan 7, 2024
1 parent 3e0bdfe commit a2ea849
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions sponsors/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,12 @@ def has_delete_permission(self, request, obj=None):
return obj.open_for_editing

def get_queryset(self, request):
qs = super().get_queryset(request)
#filters the available benefits by the benefits for the year of the sponsorship
match = request.resolver_match

sponsorship = self.parent_model.objects.get(pk=match.kwargs["object_id"])
year = sponsorship.year
filtered = qs.filter(sponsorship_benefit__year=year)

return filtered
return super().get_queryset(request).filter(sponsorship_benefit__year=year)


class TargetableEmailBenefitsFilter(admin.SimpleListFilter):
Expand Down

0 comments on commit a2ea849

Please sign in to comment.