Skip to content

Commit

Permalink
Merge pull request #109 from dudtlstm/main
Browse files Browse the repository at this point in the history
🩹 Fix:수정
  • Loading branch information
dudtlstm authored Oct 7, 2024
2 parents 947a1b2 + 6f742ed commit 74b15f8
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions booth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,12 @@ class Booth(models.Model):
open_time = models.DateTimeField(verbose_name="시작 시간")
close_time = models.DateTimeField(verbose_name="마감 시간")

@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 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)

def __str__(self):
return self.name
Expand Down

0 comments on commit 74b15f8

Please sign in to comment.