fix
This commit is contained in:
@@ -9,14 +9,14 @@ class CommentAPI(APIView):
|
|||||||
@super_admin_required
|
@super_admin_required
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
comments = Comment.objects.select_related("problem").exclude(content="")
|
comments = Comment.objects.select_related("problem").exclude(content="")
|
||||||
problem_id = request.GET.get("problem_id")
|
problem_id = request.GET.get("problem")
|
||||||
if problem_id:
|
if problem_id:
|
||||||
try:
|
try:
|
||||||
# 这里如果题目不可见,也需要显示该题目的评论
|
# 这里如果题目不可见,也需要显示该题目的评论
|
||||||
problem = Problem.objects.get(_id=problem_id, contest_id__isnull=True)
|
problem = Problem.objects.get(_id=problem_id, contest_id__isnull=True)
|
||||||
except Problem.DoesNotExist:
|
except Problem.DoesNotExist:
|
||||||
return self.error("Problem doesn't exist")
|
return self.error("Problem doesn't exist")
|
||||||
comments = comments.filter(problem=problem)
|
comments = comments.filter(problem=problem)
|
||||||
return self.success(
|
return self.success(
|
||||||
self.paginate_data(request, comments, CommentListSerializer)
|
self.paginate_data(request, comments, CommentListSerializer)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ urlpatterns = [
|
|||||||
path("api/admin/", include("utils.urls")),
|
path("api/admin/", include("utils.urls")),
|
||||||
path("api/", include("message.urls.oj")),
|
path("api/", include("message.urls.oj")),
|
||||||
path("api/", include("comment.urls.oj")),
|
path("api/", include("comment.urls.oj")),
|
||||||
path("api/admin", include("comment.urls.admin")),
|
path("api/admin/", include("comment.urls.admin")),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user