diff --git a/backend/problem/serializers.py b/backend/problem/serializers.py index cf0986999..49076d718 100644 --- a/backend/problem/serializers.py +++ b/backend/problem/serializers.py @@ -131,7 +131,7 @@ class BaseProblemSerializer(serializers.ModelSerializer): def get_contest_name(self, obj): if obj.contest: return obj.contest.title - + def get_assignment_name(self, obj): if obj.assignment: return obj.assignment.title diff --git a/backend/problem/views/admin.py b/backend/problem/views/admin.py index 3f02af3ef..eb917b68f 100644 --- a/backend/problem/views/admin.py +++ b/backend/problem/views/admin.py @@ -9,6 +9,7 @@ from django.http import StreamingHttpResponse from contest.models import Contest, ContestStatus +from course.models import Course from judge.dispatcher import SPJCompiler from submission.models import Submission from utils.api import APIView, CSRFExemptAPIView, validate_serializer, APIError diff --git a/backend/problem/views/professor.py b/backend/problem/views/professor.py index af1334dcf..18a65665d 100644 --- a/backend/problem/views/professor.py +++ b/backend/problem/views/professor.py @@ -283,7 +283,7 @@ def get(self, request): @admin_role_required def post(self, request): data = request.data - + try: course = Course.objects.get(id=data.pop("course_id")) ensure_created_by(course, request.user) diff --git a/backend/submission/views.py b/backend/submission/views.py index c91f53d9d..091bfdc21 100644 --- a/backend/submission/views.py +++ b/backend/submission/views.py @@ -78,7 +78,11 @@ def post(self, request): return self.error(error) try: - problem = Problem.objects.get(id=data["problem_id"], contest_id=data.get("contest_id"), assignment_id=data.get("assignment_id"), course_id=data.get("course_id"), visible=True) + problem = Problem.objects.get(id=data["problem_id"], + contest_id=data.get("contest_id"), + assignment_id=data.get("assignment_id"), + course_id=data.get("course_id"), + visible=True) except Problem.DoesNotExist: return self.error("Problem not exist") if data["language"] not in problem.languages: