From 117fb938a08ca28cb336d882564a591e9f4de0c9 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sat, 9 Dec 2023 13:21:45 +0100 Subject: [PATCH] Fix tests --- competition/serializers.py | 17 ++++++++++++++--- competition/tests.py | 2 -- competition/views.py | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/competition/serializers.py b/competition/serializers.py index 4e4feb49..031ca1cd 100644 --- a/competition/serializers.py +++ b/competition/serializers.py @@ -210,9 +210,15 @@ class Meta: @ts_interface(context='competition') class SeriesSerializer(serializers.ModelSerializer): + complete = serializers.SerializerMethodField('get_complete') + class Meta: model = models.Series - exclude = ['sum_method'] + read_only_fields = ['complete'] + fields = ['semester', 'order', 'deadline', 'complete'] + + def get_complete(self, obj: models.Series): + return obj.complete @ts_interface(context='competition') @@ -284,15 +290,20 @@ class SeriesWithProblemsSerializer(ModelWithParticipationSerializer): ) can_submit = serializers.SerializerMethodField('get_can_submit') can_resubmit = serializers.SerializerMethodField('get_can_resubmit') + complete = serializers.SerializerMethodField('get_complete') class Meta: model = models.Series - exclude = ['sum_method'] - read_only_fields = ['semester'] + exclude = ['sum_method', 'frozen_results'] + include = ['complete'] + read_only_fields = ['semester', 'complete'] def get_can_submit(self, obj): return obj.can_submit + def get_complete(self, obj: models.Series): + return obj.complete + def get_can_resubmit(self, obj): return obj.can_resubmit diff --git a/competition/tests.py b/competition/tests.py index 4df28c50..d0701c51 100644 --- a/competition/tests.py +++ b/competition/tests.py @@ -12,7 +12,6 @@ 'order', 'deadline', 'complete', - 'frozen_results', 'semester', ] @@ -47,7 +46,6 @@ 'start', 'end', 'season_code', - 'frozen_results', 'competition', 'late_tags', ] diff --git a/competition/views.py b/competition/views.py index 30ccceae..aa4a738b 100644 --- a/competition/views.py +++ b/competition/views.py @@ -494,7 +494,7 @@ def current(self, request, competition_id=None): """Vráti aktuálnu sériu""" items = Semester.objects.filter( competition=competition_id - ).current().series_set.filter(complete=False)\ + ).current().series_set.filter(frozen_results__isnull=True)\ .order_by('-deadline')\ .first() serializer = SeriesWithProblemsSerializer(items, many=False)