Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion booth/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
booth_waiting_router.register(r'booths-waiting', BoothWaitingStatusViewSet, basename='booth-waiting')

GDGbooth_router = routers.SimpleRouter(trailing_slash=False)
GDGbooth_router.register(r'gdg-booths', GDGBoothViewSet, basename='booth')
GDGbooth_router.register(r'gdg-booths', GDGBoothViewSet, basename='gdg-booth')

booth_for_admin_router = routers.SimpleRouter(trailing_slash=False)
booth_for_admin_router.register(r'booths-for-admin', BoothForAdminViewSet, basename='booth-for-admin')

urlpatterns = [
path('', include(booth_router.urls)),
path('', include(GDGbooth_router.urls)),
path('', include(booth_waiting_router.urls)),
path('', include(booth_for_admin_router.urls)),
path('upload-booth-data', BoothDataView.as_view(), name="upload_booth_data")
]
63 changes: 62 additions & 1 deletion booth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def set_booth_finished(self, request):
code=status.HTTP_500_INTERNAL_SERVER_ERROR,
success=False
)


class BoothWaitingStatusViewSet(CustomResponseMixin, viewsets.GenericViewSet, mixins.RetrieveModelMixin, mixins.ListModelMixin):
"""
Expand Down Expand Up @@ -382,4 +381,66 @@ def retrieve(self, request, *args, **kwargs):
message='GDG부스 상세 조회 실패',
code=status.HTTP_500_INTERNAL_SERVER_ERROR,
success=False
)

class BoothForAdminViewSet(CustomResponseMixin, viewsets.GenericViewSet, mixins.RetrieveModelMixin, mixins.ListModelMixin):
"""
- GET /booths-for-admin -> 부스 목록(가나다순)
- GET /booths-for-admin/{pk} -> 부스 상세
"""

def get_serializer_class(self):
if self.action == 'list':
return BoothListSerializer
return BoothDetailSerializer

def get_queryset(self):
# '운영중 - 대기중지 - 운영전 - 운영종료' + 가나다 순서로 정렬
queryset = Booth.objects.all().annotate(
operating_status_order=Case(
When(operating_status='operating', then=Value(1)),
When(operating_status='paused', then=Value(2)),
When(operating_status='not_started', then=Value(3)),
When(operating_status='finished', then=Value(4)),
output_field=IntegerField()
)
)
return queryset.order_by('operating_status_order', 'booth_name')

# 부스 목록 조회
def list(self, request, *args, **kwargs):
try:
queryset = self.get_queryset()
serializer = self.get_serializer(queryset, many=True)
return custom_response(
data=serializer.data,
message='부스 목록 조회 성공',
code=status.HTTP_200_OK
)
except Exception as e:
return custom_response(
data={'detail': str(e)},
message='부스 목록 조회 실패',
code=status.HTTP_500_INTERNAL_SERVER_ERROR,
success=False
)

#부스 상세 조회
def retrieve(self, request, *args, **kwargs):
try:
booth = self.get_object()

serializer = self.get_serializer(booth)
return custom_response(
data=serializer.data,
message="부스 상세 조회 성공",
code=status.HTTP_200_OK
)

except Exception as e:
return custom_response(
data={'detail': str(e)},
message='부스 상세 조회 실패',
code=status.HTTP_500_INTERNAL_SERVER_ERROR,
success=False
)