Fixes issue with in progress tournaments

clubs
Laurent 1 year ago
parent 67aa8c25d1
commit 526aa6f665
  1. 2
      tournaments/models/tournament.py
  2. 17
      tournaments/views.py

@ -535,7 +535,7 @@ class Tournament(models.Model):
def supposedly_in_progress(self):
end = self.start_date + timedelta(days=self.day_duration)
return timezone.now() > self.start_date.replace(hour=0, minute=0) and timezone.now() < end
return self.start_date.replace(hour=0, minute=0) <= timezone.now() <= end
class MatchGroup:
def __init__(self, name, matches):

@ -33,15 +33,14 @@ from qr_code.qrcode.utils import QRCodeOptions
def index(request):
today = date.today()
tomorrow = today + timedelta(days=1)
tomorrow = date.today() + timedelta(days=1)
club_id = request.GET.get('club')
q_is_private = Q(is_private=False)
q_not_private = Q(is_private=False)
q_after_tomorrow = [q_is_private, Q(end_date__isnull=True, start_date__gt=tomorrow)]
q_after_today = [q_is_private, Q(end_date__isnull=True, start_date__gt=today)]
q_ended = [q_is_private, Q(end_date__isnull=False)]
q_after_tomorrow = [q_not_private, Q(end_date__isnull=True, start_date__gt=tomorrow)]
q_unfinished = [q_not_private, Q(end_date__isnull=True)]
q_ended = [q_not_private, Q(end_date__isnull=False)]
club = None
if club_id:
@ -49,14 +48,14 @@ def index(request):
q_club = Q(event__club=club)
q_after_tomorrow.append(q_club)
q_after_today.append(q_club)
q_unfinished.append(q_club)
q_ended.append(q_club)
after_tomorrow_tournaments = Tournament.objects.filter(*q_after_tomorrow).order_by('start_date')
after_today_tournaments = Tournament.objects.filter(*q_after_today).order_by('start_date')
unfinished_tournaments = Tournament.objects.filter(*q_unfinished).order_by('start_date')
live_tournaments = []
for tournament in after_today_tournaments:
for tournament in unfinished_tournaments:
if tournament.supposedly_in_progress():
live_tournaments.append(tournament)

Loading…
Cancel
Save