From 65c48437a95a7d65540de7618f70ee454317e1a6 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 24 May 2026 20:44:02 -0600 Subject: [PATCH] fix --- account/views/oj.py | 2 +- comment/views/admin.py | 2 +- flowchart/views/oj.py | 2 +- problem/views/oj.py | 8 ++++---- problemset/views/admin.py | 2 +- submission/views/admin.py | 2 +- submission/views/oj.py | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/account/views/oj.py b/account/views/oj.py index 93547b6..40bc41a 100644 --- a/account/views/oj.py +++ b/account/views/oj.py @@ -479,7 +479,7 @@ class UserProblemRankAPI(APIView): if not user.is_authenticated: return self.error("User is not authenticated") - problem = Problem.objects.get(_id=problem_id, contest_id__isnull=True, visible=True) + problem = Problem.objects.get(_id__iexact=problem_id, contest_id__isnull=True, visible=True) submissions = Submission.objects.filter(problem=problem, result=JudgeStatus.ACCEPTED) all_ac_count = submissions.values("user_id").distinct().count() diff --git a/comment/views/admin.py b/comment/views/admin.py index 74806c1..2dcda9a 100644 --- a/comment/views/admin.py +++ b/comment/views/admin.py @@ -13,7 +13,7 @@ class CommentAPI(APIView): if problem_id: try: # 这里如果题目不可见,也需要显示该题目的评论 - problem = Problem.objects.get(_id=problem_id, contest_id__isnull=True) + problem = Problem.objects.get(_id__iexact=problem_id, contest_id__isnull=True) except Problem.DoesNotExist: return self.error("Problem doesn't exist") comments = comments.filter(problem=problem) diff --git a/flowchart/views/oj.py b/flowchart/views/oj.py index 3298ea7..c75a039 100644 --- a/flowchart/views/oj.py +++ b/flowchart/views/oj.py @@ -75,7 +75,7 @@ class FlowchartSubmissionListAPI(APIView): if problem_id: try: problem = Problem.objects.get( - _id=problem_id, contest_id__isnull=True, visible=True + _id__iexact=problem_id, contest_id__isnull=True, visible=True ) except Problem.DoesNotExist: return self.error("Problem doesn't exist") diff --git a/problem/views/oj.py b/problem/views/oj.py index 4ce1f1b..c2a6e94 100644 --- a/problem/views/oj.py +++ b/problem/views/oj.py @@ -70,7 +70,7 @@ class ProblemAPI(APIView): if problem_id: try: problem = Problem.objects.select_related("created_by").get( - _id=problem_id, contest_id__isnull=True, visible=True + _id__iexact=problem_id, contest_id__isnull=True, visible=True ) problem_data = ProblemSerializer(problem).data self._add_problem_status(request, problem_data) @@ -160,7 +160,7 @@ class ContestProblemAPI(APIView): if problem_id: try: problem = Problem.objects.select_related("created_by").get( - _id=problem_id, contest=self.contest, visible=True + _id__iexact=problem_id, contest=self.contest, visible=True ) except Problem.DoesNotExist: return self.error("Problem does not exist.") @@ -224,7 +224,7 @@ class SimilarProblemAPI(APIView): return self.error("problem_id is required") try: - problem = Problem.objects.get(_id=problem_display_id, contest__isnull=True) + problem = Problem.objects.get(_id__iexact=problem_display_id, contest__isnull=True) except Problem.DoesNotExist: return self.error("Problem not found") @@ -295,7 +295,7 @@ class ProblemYearlyACRateAPI(APIView): try: problem = Problem.objects.get( - _id=problem_id, contest_id__isnull=True, visible=True + _id__iexact=problem_id, contest_id__isnull=True, visible=True ) except Problem.DoesNotExist: return self.error("Problem does not exist") diff --git a/problemset/views/admin.py b/problemset/views/admin.py index 8d2df2f..6f26ec8 100644 --- a/problemset/views/admin.py +++ b/problemset/views/admin.py @@ -141,7 +141,7 @@ class ProblemSetProblemAdminAPI(APIView): data = request.data try: problem = Problem.objects.filter( - _id=data["problem_id"], + _id__iexact=data["problem_id"], visible=True, contest_id__isnull=True, ).get() diff --git a/submission/views/admin.py b/submission/views/admin.py index b0b36d2..aa650a6 100644 --- a/submission/views/admin.py +++ b/submission/views/admin.py @@ -52,7 +52,7 @@ class SubmissionStatisticsAPI(APIView): if problem_id: try: problem = Problem.objects.get( - _id=problem_id, contest_id__isnull=True, visible=True + _id__iexact=problem_id, contest_id__isnull=True, visible=True ) except Problem.DoesNotExist: return self.error("Problem doesn't exist") diff --git a/submission/views/oj.py b/submission/views/oj.py index ee799cb..29a0d2e 100644 --- a/submission/views/oj.py +++ b/submission/views/oj.py @@ -172,7 +172,7 @@ class SubmissionListAPI(APIView): if problem_id: try: problem = Problem.objects.get( - _id=problem_id, contest_id__isnull=True, visible=True + _id__iexact=problem_id, contest_id__isnull=True, visible=True ) except Problem.DoesNotExist: return self.error("Problem doesn't exist") @@ -225,7 +225,7 @@ class ContestSubmissionListAPI(APIView): if problem_id: try: problem = Problem.objects.get( - _id=problem_id, contest_id=contest.id, visible=True + _id__iexact=problem_id, contest_id=contest.id, visible=True ) except Problem.DoesNotExist: return self.error("Problem doesn't exist")