services.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Odin 作者: HackSoftware 项目源码 文件源码
def create_gradable_solution(*,
                             task: CompetitionTask,
                             participant: CompetitionParticipant,
                             code: str=None,
                             file: BinaryIO=None) -> Solution:
    if code is not None and file is not None:
        raise ValidationError("Provide either code or a file, not both!")
    if code is None and file is None:
        raise ValidationError("Provide either code or a file!")
    if not CompetitionTest.objects.filter(task=task).exists():
        raise ValidationError("This task does not have tests yet")
    if code is not None:
        new_solution = Solution.objects.create(
            task=task,
            participant=participant,
            code=code,
            status=6
        )
    if file is not None:
        new_solution = Solution.objects.create(
            task=task,
            participant=participant,
            file=file,
            status=6
        )

    return new_solution
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号