Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 Fix: is_waiting, waiting_status 반영 잘 되게 #103

Merged
merged 1 commit into from
Oct 7, 2024
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
21 changes: 15 additions & 6 deletions booth/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ def get_waiting_count(self, obj):
def get_is_waiting(self, obj):
request = self.context.get('request')
if request and request.user.is_authenticated:
return Waiting.objects.filter(user=request.user, booth=obj).exists()
return Waiting.objects.filter(
user=request.user,
booth=obj,
waiting_status__in=['waiting', 'ready_to_confirm', 'confirmed']
).exists()
return False

# μ—¬λŸ¬ 번 λŒ€κΈ°λ₯Ό κ±Έμ—ˆμ„ λ•Œ κ°€μž₯ 졜근의 statusλ₯Ό 반영
def get_waiting_status(self, obj):
request = self.context.get('request')
if request and request.user.is_authenticated:
waiting = Waiting.objects.filter(user=request.user, booth=obj).first()
waiting = Waiting.objects.filter(user=request.user, booth=obj).order_by('-registered_at').first()
if waiting:
return waiting.waiting_status
return None
Expand All @@ -72,17 +77,21 @@ class Meta:
def get_waiting_count(self, obj):
return obj.waitings.count()

# μ‚¬μš©μž λŒ€κΈ° κ΄€λ ¨
# μ‚¬μš©μž λŒ€κΈ° κ΄€λ ¨
def get_is_waiting(self, obj):
request = self.context.get('request')
if request and request.user.is_authenticated:
return Waiting.objects.filter(user=request.user, booth=obj).exists()
return Waiting.objects.filter(
user=request.user,
booth=obj,
waiting_status__in=['waiting', 'ready_to_confirm', 'confirmed']
).exists()
return False

def get_waiting_status(self, obj):
request = self.context.get('request')
if request and request.user.is_authenticated:
waiting = Waiting.objects.filter(user=request.user, booth=obj).first()
waiting = Waiting.objects.filter(user=request.user, booth=obj).order_by('-registered_at').first()
if waiting:
return waiting.waiting_status
return None
return None
Loading