Skip to content

Commit

Permalink
Current series (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe authored Nov 22, 2024
1 parent b2c439b commit 1838753
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.core.mail import send_mail
from django.http import FileResponse, HttpResponse
from django.template.loader import render_to_string
from django.utils.timezone import now
from rest_framework import exceptions, mixins, status, viewsets
from rest_framework.decorators import action
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -528,12 +529,17 @@ def stats(self, request, pk=None):
@action(methods=['get'], detail=False, url_path=r'current/(?P<competition_id>\d+)')
def current(self, request, competition_id=None):
"""Vráti aktuálnu sériu"""
items = Semester.objects.filter(
current_semester_series = Semester.objects.filter(
competition=competition_id
).current().series_set.filter(frozen_results__isnull=True)\
.order_by('-deadline')\
.first()
serializer = SeriesWithProblemsSerializer(items, many=False)
).current().series_set
current_series = current_semester_series.filter(
deadline__gte=now()
).order_by('deadline').first()
if current_series is None:
current_series = current_semester_series.order_by(
'-deadline').first()
serializer = SeriesWithProblemsSerializer(
current_series, many=False)
return Response(serializer.data, status=status.HTTP_200_OK)


Expand Down

0 comments on commit 1838753

Please sign in to comment.