Skip to content

Commit 45347c8

Browse files
committed
Fix: 후원사 목록 조회 시 등급 별로 조회 되도록 수정
1 parent 0f4719a commit 45347c8

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

pyconkr/settings.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
For the full list of settings and their values, see
1010
https://docs.djangoproject.com/en/4.1/ref/settings/
1111
"""
12+
1213
import os
1314
import pathlib
1415

@@ -81,9 +82,10 @@
8182
TEMPLATES = [
8283
{
8384
"BACKEND": "django.template.backends.django.DjangoTemplates",
84-
"DIRS": [BASE_DIR / "templates" ,
85-
BASE_DIR / "accounts/templates",
86-
],
85+
"DIRS": [
86+
BASE_DIR / "templates",
87+
BASE_DIR / "accounts/templates",
88+
],
8789
"APP_DIRS": True,
8890
"OPTIONS": {
8991
"context_processors": [
@@ -139,7 +141,9 @@
139141
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
140142

141143
AUTH_PASSWORD_VALIDATORS = [
142-
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
144+
{
145+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
146+
},
143147
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
144148
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
145149
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
@@ -219,7 +223,7 @@
219223
"https://2023.pycon.kr",
220224
"https://pycon-dev2023.pycon.kr",
221225
"https://pycon-prod2023.pycon.kr",
222-
"https://ticket-2023.pycon.kr", # PG 심사 대비 임시 도메인
226+
"https://ticket-2023.pycon.kr", # PG 심사 대비 임시 도메인
223227
"https://127.0.0.1:3000",
224228
"https://localhost:3000",
225229
"http://2023.pycon.kr",

sponsor/serializers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ class Meta:
9797
read_only_fields = ["id"]
9898

9999

100+
class SponsorWithLevelSerializer(serializers.ModelSerializer):
101+
sponsor = SponsorSerializer(read_only=True, many=True, source="sponsor_set")
102+
103+
class Meta:
104+
model = SponsorLevel
105+
fields = ["name", "order", "sponsor"]
106+
107+
100108
class SponsorDetailSerializer(serializers.ModelSerializer):
101109
creator_userid = serializers.SerializerMethodField()
102110

sponsor/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)
99

1010
urlpatterns = [
11-
path("list/", SponsorViewSet.as_view({"get": "list"})),
11+
path("list/", SponsorViewSet.as_view({"get": "list", "post": "create"})),
1212
path(
1313
"list/<int:id>/",
1414
SponsorViewSet.as_view({"get": "retrieve", "put": "update"}),

sponsor/viewsets.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from sponsor.serializers import (
1515
PatronListSerializer,
1616
SponsorDetailSerializer,
17-
SponsorListSerializer,
17+
SponsorWithLevelSerializer,
1818
SponsorRemainingAccountSerializer,
1919
SponsorSerializer,
2020
SponsorLevelSerializer,
@@ -79,7 +79,6 @@ class SponsorViewSet(
7979
viewsets.GenericViewSet,
8080
):
8181
queryset = Sponsor.objects.all()
82-
serializer_class = SponsorSerializer
8382
permission_classes = [IsOwnerOrReadOnly] # 본인 소유만 수정 가능
8483
validator = SponsorValidater()
8584

@@ -93,7 +92,7 @@ def get_queryset(self):
9392

9493
def get_serializer_class(self):
9594
if self.action == "list":
96-
return SponsorListSerializer
95+
return SponsorWithLevelSerializer
9796
return SponsorSerializer
9897

9998
@atomic
@@ -102,7 +101,7 @@ def create(self, request, *args, **kwargs):
102101
serializer.is_valid(raise_exception=True)
103102
self.validator.assert_create(serializer.validated_data)
104103

105-
new_sponsor = serializer.save()
104+
serializer.save()
106105

107106
# slack 알림을 실패하더라도 transaction 전체를 롤백하지는 않아야 함
108107
# TODO 람다 외부 인터넷 접근 확인 후 활성화

0 commit comments

Comments
 (0)