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: settings.py renderer μΆ”κ°€ #108

Merged
merged 2 commits into from
Oct 7, 2024
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
17 changes: 11 additions & 6 deletions booth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ class Booth(models.Model):
open_time = models.DateTimeField(verbose_name="μ‹œμž‘ μ‹œκ°„")
close_time = models.DateTimeField(verbose_name="마감 μ‹œκ°„")

def save(self, *args, **kwargs):
if self.is_operated == 'operating' and self.open_time is None:
self.open_time = timezone.now()
elif self.is_operated == 'finished' and self.close_time is None:
self.close_time = timezone.now()
super().save(*args, **kwargs)
@property
def is_operated(self):
current_time = timezone.now()
if self.open_time and self.close_time:
if self.open_time <= current_time < self.close_time:
return 'operating' # 운영 μ‹œκ°„ 내이면 '운영 쀑'
elif current_time >= self.close_time:
return 'finished' # 마감 μ‹œκ°„μ„ λ„˜κ²ΌμœΌλ©΄ '운영 μ’…λ£Œ'
else:
return 'not_started' # 아직 μ‹œμž‘ μ‹œκ°„μ΄ λ˜μ§€ μ•Šμ•˜μœΌλ©΄ '운영 μ „'
return 'not_started'

def __str__(self):
return self.name
Expand Down
3 changes: 3 additions & 0 deletions linenow/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
),
'EXCEPTION_HANDLER': 'utils.exceptions.custom_exception_handler',
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
}

REST_AUTH = {
Expand Down
Loading