From 4f41eed5026db1ff60a360f13a9e6b904901aeeb Mon Sep 17 00:00:00 2001 From: dudtlstm Date: Mon, 7 Oct 2024 16:32:03 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Feat:=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EC=9A=B4?= =?UTF-8?q?=EC=98=81=20=EC=83=81=ED=83=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- booth/models.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/booth/models.py b/booth/models.py index a0231e5..e76214c 100644 --- a/booth/models.py +++ b/booth/models.py @@ -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 From 5cb367a13c5ea1a497a24a245f63ab341d71a35b Mon Sep 17 00:00:00 2001 From: dudtlstm Date: Mon, 7 Oct 2024 16:33:13 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A9=B9=20Fix:=20settings.py=20rendere?= =?UTF-8?q?r=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- linenow/settings.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linenow/settings.py b/linenow/settings.py index 7302d17..fd5aab5 100644 --- a/linenow/settings.py +++ b/linenow/settings.py @@ -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 = {