Raz 8 months ago
commit 6272e11f21
  1. 13
      tournaments/models/tournament.py
  2. 5
      tournaments/views.py

@ -170,7 +170,7 @@ class Tournament(models.Model):
return self.get_federal_age_category_display()
def formatted_start_date(self):
return self.start_date.strftime("%d/%m/%y")
return self.local_start_date().strftime("%d/%m/%y")
def in_progress(self):
return self.end_date is None
@ -936,7 +936,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()
@ -950,6 +950,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