Skip to content

Commit

Permalink
Merge pull request #174 from pythonkr/fix/sponsor-admin
Browse files Browse the repository at this point in the history
어드민 페이지에서 후원사 정보가 보기 편하도록 수정
  • Loading branch information
jungmir authored Oct 5, 2024
2 parents 91164b4 + 6c82021 commit d6cc378
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion sponsor/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class SponsorAdmin(SummernoteModelAdmin):
"submitted",
"accepted",
"paid_at",
"year",
)
list_filter = ("accepted", "submitted")
list_filter = ("accepted", "submitted", "paid_at")
ordering = ("-created_at",)


Expand Down
2 changes: 1 addition & 1 deletion sponsor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def accepted_count(self):
return Sponsor.objects.filter(level=self, submitted=True, accepted=True).count()

def __str__(self):
return self.name
return f"({self.year}) {self.name}"


class BenefitByLevel(models.Model):
Expand Down
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 d6cc378

Please sign in to comment.