mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-04 03:22:06 +00:00
[API]添加获取比赛提交adminAPI^C
This commit is contained in:
parent
d2515bf886
commit
1c835cfa2e
@ -21,6 +21,7 @@ from utils.shortcuts import serializer_invalid_response, error_response, success
|
||||
|
||||
from submission.models import Submission
|
||||
from .serializers import CreateContestSubmissionSerializer
|
||||
from submission.serializers import SubmissionSerializer
|
||||
|
||||
|
||||
class ContestSubmissionAPIView(APIView):
|
||||
@ -76,7 +77,8 @@ def contest_problem_my_submissions_list_page(request, contest_id, contest_proble
|
||||
contest_problem = ContestProblem.objects.get(id=contest_problem_id, visible=True)
|
||||
except Problem.DoesNotExist:
|
||||
return error_page(request, u"比赛问题不存在")
|
||||
submissions = Submission.objects.filter(user_id=request.user.id, problem_id=contest_problem.id).order_by("-create_time"). \
|
||||
submissions = Submission.objects.filter(user_id=request.user.id, problem_id=contest_problem.id).order_by(
|
||||
"-create_time"). \
|
||||
values("id", "result", "create_time", "accepted_answer_time", "language")
|
||||
return render(request, "oj/contest/my_submissions_list.html",
|
||||
{"submissions": submissions, "problem": contest_problem})
|
||||
@ -112,4 +114,36 @@ def contest_problem_submissions_list_page(request, contest_id, page=1):
|
||||
return render(request, "oj/contest/submissions_list.html",
|
||||
{"submissions": current_page, "page": int(page),
|
||||
"previous_page": previous_page, "next_page": next_page, "start_id": int(page) * 20 - 20,
|
||||
"contest": contest})
|
||||
"contest": contest})
|
||||
|
||||
|
||||
class ContestSubmissionAdminAPIView(APIView):
|
||||
def get(self, request):
|
||||
"""
|
||||
查询比赛提交,单个比赛题目提交的adminAPI
|
||||
---
|
||||
response_serializer: SubmissionSerializer
|
||||
"""
|
||||
problem_id = request.GET.get("problem_id", None)
|
||||
contest_id = request.GET.get("contest_id", None)
|
||||
if contest_id:
|
||||
try:
|
||||
contest = Contest.objects.get(pk=contest_id)
|
||||
except Contest.DoesNotExist:
|
||||
return error_response(u"比赛不存在!")
|
||||
if request.user.admin_type != SUPER_ADMIN and contest.created_by != request.user:
|
||||
return error_response(u"您无权查看该信息!")
|
||||
submissions = Submission.objects.filter(contest_id=contest_id).order_by("-create_time")
|
||||
else:
|
||||
if problem_id:
|
||||
try:
|
||||
contest_problem = ContestProblem.objects.get(pk=problem_id)
|
||||
except ContestProblem.DoesNotExist:
|
||||
return error_response(u"问题不存在!")
|
||||
submissions = Submission.objects.filter(contest_id=contest_problem.contest_id).order_by("-create_time")
|
||||
else:
|
||||
return error_response(u"参数错误!")
|
||||
if problem_id:
|
||||
submissions = submissions.filter(problem_id=problem_id)
|
||||
|
||||
return paginate(request, submissions, SubmissionSerializer)
|
||||
|
@ -17,7 +17,7 @@ from admin.views import AdminTemplateView
|
||||
|
||||
from problem.views import TestCaseUploadAPIView, ProblemTagAdminAPIView, ProblemAdminAPIView
|
||||
from submission.views import SubmissionAPIView, SubmissionAdminAPIView
|
||||
from contest_submission.views import ContestSubmissionAPIView
|
||||
from contest_submission.views import ContestSubmissionAPIView, ContestSubmissionAdminAPIView
|
||||
from monitor.views import QueueLengthMonitorAPIView
|
||||
|
||||
from contest_submission.views import contest_problem_my_submissions_list_page
|
||||
@ -65,7 +65,7 @@ urlpatterns = [
|
||||
name="join_group_request_admin_api"),
|
||||
url(r'^api/admin/submission/$', SubmissionAdminAPIView.as_view(), name="submission_admin_api_view"),
|
||||
url(r'^api/admin/monitor/$', QueueLengthMonitorAPIView.as_view(), name="queue_length_monitor_api"),
|
||||
|
||||
url(r'^api/admin/contest_submission/$', ContestSubmissionAdminAPIView.as_view(), name="contest_submission_admin_api_view"),
|
||||
|
||||
|
||||
url(r'^contest/(?P<contest_id>\d+)/problem/(?P<contest_problem_id>\d+)/$', "contest.views.contest_problem_page",
|
||||
|
Loading…
Reference in New Issue
Block a user