Skip to content

Commit

Permalink
kahluaband#87 Feat: add participants list in general ticket admin
Browse files Browse the repository at this point in the history
  • Loading branch information
강지윤 authored and 강지윤 committed Mar 1, 2024
1 parent ce185ff commit 3e1dc98
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
11 changes: 11 additions & 0 deletions kahlua_admin/serializers/tickets_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class GeneralTicketAdminListSerializer(serializers.ModelSerializer):
buyer = serializers.SerializerMethodField()
phone_num = serializers.SerializerMethodField()
member = serializers.SerializerMethodField()
participants = serializers.SerializerMethodField()

class Meta:
model = OrderTransaction
Expand All @@ -33,6 +34,7 @@ class Meta:
'member',
'merchant_order_id',
'transaction_status',
'participants',
]

def get_buyer(self, obj):
Expand All @@ -55,3 +57,12 @@ def get_member(self, obj):
'''
ticket = obj.order
return ticket.member

def get_participants(self, obj):
'''
구매자가 구매한 티켓의 참석자를 알려주기 위한 함수
'''
participants_list = []
for participant in obj.order.participants.all():
participants_list.append({'name': participant.name, 'phone_num': participant.phone_num})
return participants_list
5 changes: 3 additions & 2 deletions kahlua_admin/views/tickets_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class GeneralTicketListViewSet(viewsets.ModelViewSet):
"phone_num": "01012345678",
"member": 2,
"merchant_order_id": "734ea4eadf",
"transaction_status": "paid"
"transaction_status": "paid",
"participants": "[{'name': '깔루아', 'phone_num': '01012345678'}, {'name': '깔루아', 'phone_num': '01012345678'}]",
},
}
}
Expand All @@ -115,7 +116,7 @@ class GeneralTicketListViewSet(viewsets.ModelViewSet):
)
def list(self, request, *args, **kwargs):
order = self.get_queryset()
order_name = request.GET.get('name', False)
order_name = request.GET.get('name', False) # 이름순 정렬
if order_name:
order = OrderTransaction.objects.all().order_by('order__buyer')

Expand Down
4 changes: 2 additions & 2 deletions tickets/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ class Meta:
)
def create(self, request, *args, **kwargs):
order_info = request.POST.copy()
name_list = order_info.getlist('name')
phone_list = order_info.getlist('phone')
name_list = order_info.getlist('name[]')
phone_list = order_info.getlist('phone[]')

# if order_info['payment'] == '카카오페이':
# order_info['status'] = True
Expand Down

0 comments on commit 3e1dc98

Please sign in to comment.