mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
fix typo
This commit is contained in:
parent
4c9ffa40b0
commit
489bbb841a
@ -17,7 +17,7 @@ from utils.shortcuts import serializer_invalid_response, error_response, success
|
|||||||
from .serializers import CreateSubmissionSerializer
|
from .serializers import CreateSubmissionSerializer
|
||||||
|
|
||||||
|
|
||||||
def _create_mondodb_connection():
|
def _create_mongodb_connection():
|
||||||
mongodb_setting = settings.MONGODB
|
mongodb_setting = settings.MONGODB
|
||||||
connection = pymongo.MongoClient(host=mongodb_setting["HOST"], port=mongodb_setting["PORT"])
|
connection = pymongo.MongoClient(host=mongodb_setting["HOST"], port=mongodb_setting["PORT"])
|
||||||
return connection["oj"]["oj_submission"]
|
return connection["oj"]["oj_submission"]
|
||||||
@ -42,9 +42,7 @@ class SubmissionAPIView(APIView):
|
|||||||
problem = Problem.objects.get(id=data["problem_id"])
|
problem = Problem.objects.get(id=data["problem_id"])
|
||||||
except Problem.DoesNotExist:
|
except Problem.DoesNotExist:
|
||||||
return error_response(u"题目不存在")
|
return error_response(u"题目不存在")
|
||||||
mongodb_setting = settings.DATABASES["mongodb"]
|
collection = _create_mongodb_connection()
|
||||||
connection = pymongo.MongoClient(host=mongodb_setting["HOST"], port=mongodb_setting["PORT"])
|
|
||||||
collection = connection["oj"]["oj_submission"]
|
|
||||||
submission_id = str(collection.insert_one(data).inserted_id)
|
submission_id = str(collection.insert_one(data).inserted_id)
|
||||||
judge.delay(submission_id, problem.time_limit, problem.memory_limit, problem.test_case_id)
|
judge.delay(submission_id, problem.time_limit, problem.memory_limit, problem.test_case_id)
|
||||||
return success_response({"submission_id": submission_id})
|
return success_response({"submission_id": submission_id})
|
||||||
@ -56,7 +54,7 @@ class SubmissionAPIView(APIView):
|
|||||||
submission_id = request.GET.get("submission_id", None)
|
submission_id = request.GET.get("submission_id", None)
|
||||||
if not submission_id:
|
if not submission_id:
|
||||||
return error_response(u"参数错误")
|
return error_response(u"参数错误")
|
||||||
submission = _create_mondodb_connection().find_one({"_id": ObjectId(submission_id), "user_id": request.user.id})
|
submission = _create_mongodb_connection().find_one({"_id": ObjectId(submission_id), "user_id": request.user.id})
|
||||||
if submission:
|
if submission:
|
||||||
response_data = {"result": submission["result"]}
|
response_data = {"result": submission["result"]}
|
||||||
if submission["result"] == 0:
|
if submission["result"] == 0:
|
||||||
@ -68,7 +66,7 @@ class SubmissionAPIView(APIView):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def problem_my_submissions_list_page(request, problem_id):
|
def problem_my_submissions_list_page(request, problem_id):
|
||||||
collection = _create_mondodb_connection()
|
collection = _create_mongodb_connection()
|
||||||
submissions = collection.find({"problem_id": int(problem_id), "user_id": request.user.id},
|
submissions = collection.find({"problem_id": int(problem_id), "user_id": request.user.id},
|
||||||
projection=["result", "accepted_answer_info", "create_time", "language"],
|
projection=["result", "accepted_answer_info", "create_time", "language"],
|
||||||
sort=[["create_time", -pymongo.ASCENDING]])
|
sort=[["create_time", -pymongo.ASCENDING]])
|
||||||
@ -82,7 +80,7 @@ def problem_my_submissions_list_page(request, problem_id):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def my_submission(request, submission_id):
|
def my_submission(request, submission_id):
|
||||||
collection = _create_mondodb_connection()
|
collection = _create_mongodb_connection()
|
||||||
submission = collection.find_one({"user_id": request.user.id, "_id": ObjectId(submission_id)},
|
submission = collection.find_one({"user_id": request.user.id, "_id": ObjectId(submission_id)},
|
||||||
projection=["result", "accepted_answer_info", "create_time",
|
projection=["result", "accepted_answer_info", "create_time",
|
||||||
"language", "code", "problem_id", "info"])
|
"language", "code", "problem_id", "info"])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user