Use not only closed_at / opening_at
This commit is contained in:
parent
c5e96a7ad8
commit
a60fb84bcb
|
|
@ -471,10 +471,10 @@ class Establishment(ProjectBaseMixin, URLImageMixin, TranslatedFieldsMixin):
|
|||
now_at_est_tz = datetime.now(tz=self.tz)
|
||||
current_week = now_at_est_tz.weekday()
|
||||
schedule_for_today = self.schedule.filter(weekday=current_week).first()
|
||||
if schedule_for_today is None or schedule_for_today.closed_at is None or schedule_for_today.opening_at is None:
|
||||
if schedule_for_today is None or schedule_for_today.opening_time is None or schedule_for_today.ending_time is None:
|
||||
return False
|
||||
time_at_est_tz = now_at_est_tz.time()
|
||||
return schedule_for_today.closed_at > time_at_est_tz > schedule_for_today.opening_at
|
||||
return schedule_for_today.ending_time > time_at_est_tz > schedule_for_today.opening_time
|
||||
|
||||
@property
|
||||
def tags_indexing(self):
|
||||
|
|
|
|||
|
|
@ -39,13 +39,21 @@ class Timetable(ProjectBaseMixin):
|
|||
def closed_at_str(self):
|
||||
return str(self.closed_at) if self.closed_at else None
|
||||
|
||||
@property
|
||||
def opening_time(self):
|
||||
return self.opening_at or self.lunch_start or self.dinner_start
|
||||
|
||||
@property
|
||||
def ending_time(self):
|
||||
return self.closed_at or self.dinner_end or self.lunch_end
|
||||
|
||||
@property
|
||||
def works_at_noon(self):
|
||||
return bool(self.closed_at and self.closed_at <= self.NOON)
|
||||
return bool(self.opening_time and self.opening_time <= self.NOON)
|
||||
|
||||
@property
|
||||
def works_at_afternoon(self):
|
||||
return bool(self.closed_at and self.closed_at > self.NOON)
|
||||
return bool(self.ending_time and self.ending_time > self.NOON)
|
||||
|
||||
class Meta:
|
||||
"""Meta class."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user