Skip to content

fix: 후원금 미입금 상태인 후원사는 표시되지 않도록 수정 #170

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

Merged
merged 1 commit into from
Sep 21, 2024
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
8 changes: 6 additions & 2 deletions sponsor/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.db.transaction import atomic

from django.db.models import Prefetch
from django.shortcuts import get_object_or_404
from django.db.utils import IntegrityError
from rest_framework import mixins, status, viewsets
Expand Down Expand Up @@ -53,9 +54,12 @@ def get_serializer_class(self):

@action(detail=False, methods=["GET"], url_path="with-sponsor")
def list_with_levels(self, request, version):
serializer = self.get_serializer(
self.get_queryset().filter(sponsor__paid_at__isnull=False), many=True
queryset = self.get_queryset().prefetch_related(
Prefetch(
"sponsor_set", queryset=Sponsor.objects.filter(paid_at__isnull=False)
)
)
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)

@action(detail=False, methods=["POST"])
Expand Down
Loading