Skip to content

Commit

Permalink
Merge pull request #170 from pythonkr/feature/include-only-paid
Browse files Browse the repository at this point in the history
fix: 후원금 미입금 상태인 후원사는 표시되지 않도록 수정
  • Loading branch information
jungmir authored Sep 21, 2024
2 parents 2ab18db + 203219d commit 181fa26
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 181fa26

Please sign in to comment.