Skip to content

Commit

Permalink
Add complete field on semester
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe committed Dec 9, 2023
1 parent 7f2025d commit 45c2d02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions competition/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ def freeze_results(self, results):
raise FreezingNotClosedResults()
self.frozen_results = results

@property
def complete(self) -> bool:
return self.frozen_results is not None

@property
def is_active(self) -> bool:
return self.series_set.filter(complete=False).exists()
Expand Down
5 changes: 5 additions & 0 deletions competition/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,15 @@ class SemesterWithProblemsSerializer(ModelWithParticipationSerializer):
read_only=True
)
publication_set = PublicationSerializer(many=True, read_only=True)
complete = serializers.SerializerMethodField('get_complete')

class Meta:
model = models.Semester
exclude = ['frozen_results', 'registration_link']
read_only_fields = ['complete']

def get_complete(self, obj: models.Semester):
return obj.complete

def update(self, instance: models.Semester, validated_data):
late_tags = validated_data.pop('late_tags', [])
Expand Down

0 comments on commit 45c2d02

Please sign in to comment.