Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2342 display only benefits associated with the year of the sponsorship package being edited #2356

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions sponsors/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,13 @@ def has_delete_permission(self, request, obj=None):
return True
return obj.open_for_editing

def get_queryset(self, *args, **kwargs):
qs = super().get_queryset(*args, **kwargs)
return qs.select_related("sponsorship_benefit__program", "program")
def get_queryset(self, 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

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


class TargetableEmailBenefitsFilter(admin.SimpleListFilter):
Expand Down
Loading