diff --git a/competition/models.py b/competition/models.py index e5cc3ec0..f3bbab87 100644 --- a/competition/models.py +++ b/competition/models.py @@ -279,6 +279,13 @@ def can_submit(self): max_late_tag_value = datetime.timedelta(0) return now() < self.deadline + max_late_tag_value + @property + def can_resubmit(self): + late_flag = self.get_actual_late_flag() + if late_flag: + return late_flag.can_resubmit + return False + def get_actual_late_flag(self) -> Optional[LateTag]: """ Vráti late flag, ktorý má byť v tomto okamihu priradený riešeniu, diff --git a/competition/serializers.py b/competition/serializers.py index 655d8f9e..70151eb7 100644 --- a/competition/serializers.py +++ b/competition/serializers.py @@ -262,6 +262,7 @@ def get_series_num_solutions(self, obj): class SeriesWithProblemsSerializer(ModelWithParticipationSerializer): problems = ProblemSerializer(many=True) can_submit = serializers.SerializerMethodField('get_can_submit') + can_resubmit = serializers.SerializerMethodField('get_can_resubmit') class Meta: model = models.Series @@ -271,6 +272,9 @@ class Meta: def get_can_submit(self, obj): return obj.can_submit + def get_can_resubmit(self, obj): + return obj.can_resubmit + def get_event(self, obj): return obj.semester