diff --git a/ai/views/oj.py b/ai/views/oj.py index 951df44..3b6e899 100644 --- a/ai/views/oj.py +++ b/ai/views/oj.py @@ -234,7 +234,7 @@ class AIDetailDataAPI(APIView): return self.error("end 格式无效,请使用 ISO 8601 格式") user = request.user - if username and request.user.is_super_admin(): + if username and request.user.is_teacher_or_above(): try: user = User.objects.get(username=username) except User.DoesNotExist: @@ -444,7 +444,7 @@ class AIDurationDataAPI(APIView): username = request.GET.get("username") user = request.user - if username and request.user.is_super_admin(): + if username and request.user.is_teacher_or_above(): try: user = User.objects.get(username=username) except User.DoesNotExist: @@ -856,7 +856,7 @@ class AIHeatmapDataAPI(APIView): def get(self, request): username = request.GET.get("username") user = request.user - if username and request.user.is_super_admin(): + if username and request.user.is_teacher_or_above(): try: user = User.objects.get(username=username) except User.DoesNotExist: diff --git a/problem/views/admin.py b/problem/views/admin.py index bcaf654..e0d3348 100644 --- a/problem/views/admin.py +++ b/problem/views/admin.py @@ -11,7 +11,7 @@ from django.db.models import Count, Q from django.db.models.functions import ExtractYear from django.http import StreamingHttpResponse -from account.decorators import ensure_created_by, problem_permission_required, super_admin_required +from account.decorators import ensure_created_by, problem_permission_required, teacher_admin_required from contest.models import Contest, ContestStatus from submission.models import Submission from utils.api import APIError, APIView, CSRFExemptAPIView, validate_serializer @@ -508,7 +508,7 @@ class ProblemFlowchartAIGen(APIView): class StuckProblemsAPI(APIView): - @super_admin_required + @teacher_admin_required def get(self, request): from submission.models import JudgeStatus @@ -545,7 +545,7 @@ class StuckProblemsAPI(APIView): class TopACTrendAPI(APIView): - @super_admin_required + @teacher_admin_required def get(self, request): import datetime from collections import defaultdict diff --git a/problemset/views/oj.py b/problemset/views/oj.py index 29f6375..d704cc2 100644 --- a/problemset/views/oj.py +++ b/problemset/views/oj.py @@ -1,7 +1,7 @@ from django.db.models import Avg, Count, Prefetch, Q from django.utils import timezone -from account.decorators import admin_role_required, login_required +from account.decorators import login_required, teacher_admin_required from account.models import User from problem.models import Problem from problemset.models import ( @@ -300,7 +300,7 @@ class ProblemSetBadgeAPI(AsyncAPIView): class ProblemSetUserProgressAPI(AsyncAPIView): """题单用户进度列表API""" - @admin_role_required + @teacher_admin_required async def get(self, request, problem_set_id: int): """获取题单的用户进度列表""" try: