From 05b0b5eaf566fb518bbc14a7a97bd91d73cf2104 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sun, 12 Nov 2023 10:05:30 +0100 Subject: [PATCH 1/4] Add can resubmit on series --- competition/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/competition/models.py b/competition/models.py index 504e6cf1..3f7a83b1 100644 --- a/competition/models.py +++ b/competition/models.py @@ -279,6 +279,10 @@ def can_submit(self): max_late_tag_value = datetime.timedelta(0) return now() < self.deadline + max_late_tag_value + @property + def can_resubmit(self): + return self.get_actual_late_flag().can_resubmit + def get_actual_late_flag(self) -> Optional[LateTag]: """ Vráti late flag, ktorý má byť v tomto okamihu priradený riešeniu, From 651d09ad6ebf207726b4ccbe13eb3a0e9e14540b Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sun, 12 Nov 2023 12:54:30 +0100 Subject: [PATCH 2/4] Add can_resubmit to SeriesSerializer --- competition/serializers.py | 4 ++++ 1 file changed, 4 insertions(+) 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 From 2fe026bb818e69a38678964c22236a3063d0701b Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sun, 12 Nov 2023 13:17:44 +0100 Subject: [PATCH 3/4] Fix missing late flag --- competition/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/competition/models.py b/competition/models.py index 3f7a83b1..106e830c 100644 --- a/competition/models.py +++ b/competition/models.py @@ -281,7 +281,10 @@ def can_submit(self): @property def can_resubmit(self): - return self.get_actual_late_flag().can_resubmit + 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]: """ From 68ca5d251cc9149611721614897035e7c0e65717 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sun, 12 Nov 2023 14:14:07 +0100 Subject: [PATCH 4/4] fix handling other school --- user/serializers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user/serializers.py b/user/serializers.py index a01ae106..a6f9d5be 100644 --- a/user/serializers.py +++ b/user/serializers.py @@ -126,8 +126,8 @@ def update(self, instance, validated_data): # User sa nikdy neupdatuje preto nie je potrebné volať instance.save() instance.profile.save() instance.save() - self.handle_other_school(validated_data.pop( - 'new_school_description', None)) + self.handle_other_school(profile_data.pop( + 'school', None)) return instance def handle_other_school(self, school): @@ -137,7 +137,7 @@ def handle_other_school(self, school): if school is None: return if school.code == self.OTHER_SCHOOL_CODE: - email = self.validated_data['email'] + email = self.validated_data.get('email', '-') first_name = self.validated_data['profile']['first_name'] last_name = self.validated_data['profile']['last_name'] school_info = self.validated_data['new_school_description']