Skip to content

Commit

Permalink
Fix: 후원사 목록 조회 시 필요 없는 등급별 혜택 정보가 포함되지 않도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jungmir committed Oct 5, 2024
1 parent afb875e commit 6c82021
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions sponsor/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ class Meta:


class SponsorLevelSerializer(serializers.ModelSerializer):
benefits = SponsorBenefitWithOfferSerializer(
many=True, read_only=True, source="benefit_by_level"
)

class Meta:
model = SponsorLevel
fields = [
Expand All @@ -96,11 +92,19 @@ class Meta:
"price",
"limit",
"order",
"benefits",
]
read_only_fields = ["id"]


class SponsorLevelWithBenefitSerializer(SponsorLevelSerializer):
benefits = SponsorBenefitWithOfferSerializer(
many=True, read_only=True, source="benefit_by_level"
)

class Meta(SponsorLevelSerializer.Meta):
fields = SponsorLevelSerializer.Meta.fields + ["benefits"]


class SponsorSummariesSerializer(serializers.ModelSerializer):
class Meta:
model = Sponsor
Expand Down
4 changes: 2 additions & 2 deletions sponsor/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
PatronListSerializer,
SponsorBenefitSerializer,
SponsorDetailSerializer,
SponsorLevelSerializer,
SponsorListSerializer,
SponsorRemainingAccountSerializer,
SponsorSerializer,
SponsorWithLevelSerializer,
SponsorLevelWithBenefitSerializer,
)
from sponsor.slack import send_new_sponsor_notification
from sponsor.validators import SponsorValidater
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_serializer_class(self):
case "list_with_levels":
return SponsorWithLevelSerializer
case _:
return SponsorLevelSerializer
return SponsorLevelWithBenefitSerializer

@action(detail=False, methods=["GET"], url_path="with-sponsor")
def list_with_levels(self, request, version):
Expand Down

0 comments on commit 6c82021

Please sign in to comment.