submission.py 文件源码

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

项目:eoj3 作者: ultmaster 项目源码 文件源码
def post(self, request, cid):
        try:
            if self.contest.status != 0:
                raise ValueError("Contest is not running.")
            lang = request.POST.get('lang', '')
            if lang not in self.contest.supported_language_list:
                raise ValueError("Invalid language.")
            try:
                problem = self.contest.contestproblem_set.get(identifier=request.POST.get('problem', '')).problem_id
            except ContestProblem.DoesNotExist:
                raise ValueError("Invalid problem.")
            submission = create_submission(problem, self.user, request.POST.get('code', ''), lang,
                                           contest=self.contest, ip=get_ip(request))
            contest_participant, _ = self.contest.contestparticipant_set.get_or_create(user=self.user)
            if contest_participant.is_disabled:
                raise ValueError("You have quitted the contest.")
            judge_submission_on_contest(submission)
            return JsonResponse({"url": reverse('contest:submission_api',
                                                kwargs={'cid': self.contest.id, 'sid': submission.id})})
        except Exception as e:
            return HttpResponseBadRequest(str(e).encode())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号