mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-01 10:02:01 +00:00
fix problem admin filter bug
This commit is contained in:
parent
60ebece853
commit
808b92780f
@ -5,5 +5,5 @@ from ..views.admin import ProblemAPI, TestCaseUploadAPI, ContestProblemAPI
|
||||
urlpatterns = [
|
||||
url(r"^test_case/upload$", TestCaseUploadAPI.as_view(), name="test_case_upload_api"),
|
||||
url(r"^problem$", ProblemAPI.as_view(), name="problem_api"),
|
||||
url(r'contest/problem$', ContestProblemAPI.as_view(), name="contest_problem_api")
|
||||
url(r"^contest/problem$", ContestProblemAPI.as_view(), name="contest_problem_api")
|
||||
]
|
||||
|
@ -162,15 +162,15 @@ class ProblemAPI(APIView):
|
||||
if problem_id:
|
||||
try:
|
||||
problem = Problem.objects.get(id=problem_id)
|
||||
if not user.can_mgmt_all_problem():
|
||||
problem = problem.get(created_by=request.user)
|
||||
if not user.can_mgmt_all_problem() and problem.created_by != user:
|
||||
return self.error("Problem does not exist")
|
||||
return self.success(ProblemSerializer(problem).data)
|
||||
except Problem.DoesNotExist:
|
||||
return self.error("Problem does not exist")
|
||||
|
||||
problems = Problem.objects.all().order_by("-create_time")
|
||||
if not user.can_mgmt_all_problem():
|
||||
problems = problems.filter(created_by=request.user)
|
||||
problems = problems.filter(created_by=user)
|
||||
keyword = request.GET.get("keyword")
|
||||
if keyword:
|
||||
problems = problems.filter(title__contains=keyword)
|
||||
@ -185,8 +185,8 @@ class ProblemAPI(APIView):
|
||||
|
||||
try:
|
||||
problem = Problem.objects.get(id=problem_id)
|
||||
if not user.can_mgmt_all_problem():
|
||||
problem = problem.get(created_by=request.user)
|
||||
if not user.can_mgmt_all_problem() and problem.created_by != user:
|
||||
return self.error("Problem does not exist")
|
||||
except Problem.DoesNotExist:
|
||||
return self.error("Problem does not exist")
|
||||
|
||||
@ -290,7 +290,7 @@ class ContestProblemAPI(APIView):
|
||||
if problem_id:
|
||||
try:
|
||||
problem = ContestProblem.objects.get(id=problem_id)
|
||||
if request.user.is_admin() and problem.contest.created_by != user:
|
||||
if user.is_admin() and problem.contest.created_by != user:
|
||||
return self.error("Problem does not exist")
|
||||
except ContestProblem.DoesNotExist:
|
||||
return self.error("Problem does not exist")
|
||||
|
Loading…
Reference in New Issue
Block a user