Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…backend into master
  • Loading branch information
kovacspe committed Dec 8, 2023
2 parents fc1fe83 + 873a7c5 commit bc6fc94
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions competition/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions competition/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions user/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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']
Expand Down

0 comments on commit bc6fc94

Please sign in to comment.