Skip to content

Commit

Permalink
Pridaná validácia na počet bodov
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe committed Nov 23, 2024
1 parent a0392ec commit e07e7d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion competition/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from competition.querysets import ActiveQuerySet
from competition.utils.school_year_manipulation import \
get_school_year_end_by_date
from competition.utils.validations import validate_points
from personal.models import Profile, School
from user.models import User

Expand Down Expand Up @@ -657,7 +658,7 @@ class Meta:
verbose_name='opravené riešenie', blank=True, upload_to=get_corrected_solution_path)

score = models.PositiveSmallIntegerField(
verbose_name='body', null=True, blank=True)
verbose_name='body', null=True, blank=True, validators=[validate_points])

vote = models.IntegerField(choices=Vote.choices,
default=Vote.NONE)
Expand Down
8 changes: 8 additions & 0 deletions competition/utils/validations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.core.exceptions import ValidationError


def validate_points(value: int):
if value < 0 or value > 9:
raise ValidationError(
f'{value} je mimo povoleného rozmedzia pre body'
)

0 comments on commit e07e7d8

Please sign in to comment.