Skip to content
Merged
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
10 changes: 7 additions & 3 deletions booth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from rest_framework.decorators import action
from rest_framework.response import Response
from django.db.models import Case, When, Value, IntegerField, Count, Q
from django.utils import timezone
from rest_framework.filters import OrderingFilter
from .models import Booth
from .serializers import *
Expand All @@ -29,6 +30,7 @@ def get_serializer_class(self):
return BoothDetailSerializer

def get_queryset(self):
today = timezone.now().date()
# '운영중 - 대기중지 - 운영전 - 운영종료' + 가나다 순서로 정렬
queryset = Booth.objects.all().annotate(
operating_status_order=Case(
Expand All @@ -38,7 +40,7 @@ def get_queryset(self):
When(operating_status='finished', then=Value(4)),
output_field=IntegerField()
)
)
).filter(booth_start_time__date=today) # 오늘 부스만
return queryset.order_by('operating_status_order', 'booth_name')

# 부스 목록 조회
Expand Down Expand Up @@ -165,6 +167,7 @@ def get_serializer_class(self):
return BoothWaitingDetailSerializer

def get_queryset(self):
today = timezone.now().date()
# '운영중 - 대기중지 - 운영전 - 운영종료' + 가나다 순서로 정렬
queryset = Booth.objects.all().annotate(
operating_status_order=Case(
Expand All @@ -174,7 +177,7 @@ def get_queryset(self):
When(operating_status='finished', then=Value(4)),
output_field=IntegerField()
)
)
).filter(booth_start_time__date=today) # 오늘 부스만
return queryset.order_by('operating_status_order', 'booth_name')

# 부스 목록 - 대기 정보 조회
Expand Down Expand Up @@ -329,7 +332,8 @@ def get_serializer_class(self):
return GDGBoothDetailSerializer

def get_queryset(self):
queryset = Booth.objects.all()
today = timezone.now().date()
queryset = Booth.objects.all().filter(booth_start_time__date=today) # 오늘 부스만
return queryset.order_by('booth_name')

# 부스 목록 조회
Expand Down