fix live/future display by local dates

shop
Laurent 8 months ago
parent daa3418f35
commit 8074739d22
  1. 11
      tournaments/models/tournament.py
  2. 5
      tournaments/views.py

@ -932,7 +932,7 @@ class Tournament(models.Model):
# end = self.start_date + timedelta(days=self.day_duration + 1)
# return self.start_date.replace(hour=0, minute=0) <= timezone.now() <= end
timezoned_datetime = timezone.localtime(self.start_date)
timezoned_datetime = self.local_start_date()
end = timezoned_datetime + timedelta(days=self.day_duration + 1)
now = timezone.now()
@ -946,6 +946,15 @@ class Tournament(models.Model):
return start <= now <= end
def starts_in_the_future(self):
# tomorrow = datetime.now().date() + timedelta(days=1)
timezoned_datetime = self.local_start_date()
start = timezoned_datetime.replace(hour=0, minute=0)
now = timezone.now()
return start >= now
def should_be_over(self):
if self.end_date is not None:
return True

@ -150,9 +150,8 @@ def live_tournaments(club_id):
return [t for t in tournaments if t.display_tournament() and t.supposedly_in_progress()]
def future_tournaments(club_id):
tomorrow = datetime.now().date() + timedelta(days=1)
tournaments = tournaments_query(Q(end_date__isnull=True, start_date__gte=tomorrow), club_id, True)
return [t for t in tournaments if t.display_tournament()]
tournaments = tournaments_query(Q(end_date__isnull=True), club_id, True)
return [t for t in tournaments if t.display_tournament() and t.starts_in_the_future()]
def tournament_info(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)

Loading…
Cancel
Save