mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 01:37:11 +00:00
add task admin validators
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
|
from sys import stdout
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Count, Q
|
from django.db.models import Count, Q
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from mdeditor.fields import MDTextField
|
from mdeditor.fields import MDTextField
|
||||||
|
|
||||||
from apps.competition.models import Competition
|
from apps.competition.models import Competition
|
||||||
@@ -78,6 +80,36 @@ class CompetitionTask(BaseModel):
|
|||||||
verbose_name="кол-во проверяющих для зачета задачи",
|
verbose_name="кол-во проверяющих для зачета задачи",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
super().clean()
|
||||||
|
if self.correct_answer_file and self.type not in ["checker", "input"]:
|
||||||
|
raise ValidationError({
|
||||||
|
"type": "Если загружен файл правильного ответа, то тип проверки не может быть ручным"
|
||||||
|
})
|
||||||
|
elif not self.correct_answer_file and self.type == "review":
|
||||||
|
raise ValidationError({
|
||||||
|
"correct_answer_file": "Загрузите правильный ответ"
|
||||||
|
})
|
||||||
|
|
||||||
|
if self.answer_file_path and not self.type == "checker":
|
||||||
|
raise ValidationError({
|
||||||
|
"type": "Укажите другой тип задания: этот не совместим с путем правильного ответа"
|
||||||
|
})
|
||||||
|
elif not self.answer_file_path and self.type == "checker":
|
||||||
|
raise ValidationError({
|
||||||
|
"answer_file_path": "Введите путь правильного ответа - это нужно для корректной работы чекера"
|
||||||
|
})
|
||||||
|
|
||||||
|
if not self.reviewers and self.type == "review":
|
||||||
|
raise ValidationError({
|
||||||
|
"reviewers": "Загрузите ревьюверов - кто будет проверять задания, если не они?"
|
||||||
|
})
|
||||||
|
elif self.reviewers and not self.type == "review":
|
||||||
|
raise ValidationError({
|
||||||
|
"type": "Проверьте тип - вы ввели ревьюверов, но задание не является ручным"
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user