def submission_changeresult(request, number): # FIXME: Make a django form for this. contest = Contest.objects.get() submission = Submission.objects.get(id=number) if request.method == 'POST': if "change" in request.POST: result = submission.result if submission.result is None: result = Result() comment = File(content="Manual judgement made by " + request.user.username) comment.save() result.compiler_output_file = comment result.judgement = request.POST["judgement"] result.save() if submission.result is None: submission.status = "CHECKED" submission.result = result submission.save() team = submission.team team.new_results = True team.save() Contest.objects.get().save() # Updates 'resulttime' elif "rejudge" in request.POST: submission.autojudge = None submission.result = None submission.status = "NEW" submission.save() return HttpResponseRedirect('/jury/submission/%s/' % number) time = gettime(submission.timestamp, contest) try: result = submission.result judgement = result.judgement if result.verified_by: verified_by = result.verified_by.username else: verified_by = None except (ObjectDoesNotExist, AttributeError): judgement = "Pending..." verified_by = None judgementlist = [] for j in Result.JUDGEMENT_CHOICES: if judgement == j[0]: judgementlist.append({"name": j[0], "selected": True}) else: judgementlist.append({"name": j[0], "selected": False}) return render_to_response('jury_submission_changeresult.html', {'time': time, 'submission': submission, 'judgement': judgement, 'verified_by': verified_by, 'judgementlist': judgementlist}, context_instance=RequestContext(request))
def uploadresult(submission, judgement, compiler_output, submission_output=None, autojudge_comment=None, check_output=None): result = Result() result.judgement = judgement result.judged_by = autojudge compiler_output_file = File(content=compiler_output) compiler_output_file.save() result.compiler_output_file = compiler_output_file if submission_output: submission_output_file = File() try: submission_output_file.content = submission_output.decode("utf-8") except UnicodeError: submission_output_file.content = submission_output.decode("iso8859-1") submission_output_file.save() result.submission_output_file = submission_output_file if autojudge_comment: autojudge_comment_file = File(content=autojudge_comment) autojudge_comment_file.save() result.autojudge_comment_file = autojudge_comment_file if check_output: check_output_file = File() try: check_output_file.content = check_output.decode("utf-8") except UnicodeError: check_output_file.content = check_output.decode("iso8859-1") check_output_file.save() result.check_output_file = check_output_file result.save() submission.status = "CHECKED" submission.result = result submission.save() Contest.objects.get().save() # Updates 'resulttime' team = submission.team team.new_results = True team.save()