修复几处visible未过滤的问题

This commit is contained in:
zema1 2017-12-15 20:54:30 +08:00
parent 8749e4a19a
commit 417337c4d2
3 changed files with 4 additions and 4 deletions

View File

@ -396,7 +396,7 @@ class ProfileProblemDisplayIDRefreshAPI(APIView):
ids = list(acm_problems.keys()) + list(oi_problems.keys())
if not ids:
return self.success()
display_ids = Problem.objects.filter(id__in=ids).values_list("_id", flat=True)
display_ids = Problem.objects.filter(id__in=ids, visible=True).values_list("_id", flat=True)
id_map = dict(zip(ids, display_ids))
for k, v in acm_problems.items():
v["_id"] = id_map[k]

View File

@ -32,7 +32,7 @@ class ContestAPI(APIView):
if not id:
return self.error("Invalid parameter, id is required")
try:
contest = Contest.objects.get(id=id)
contest = Contest.objects.get(id=id, visible=True)
except Contest.DoesNotExist:
return self.error("Contest does not exist")
data = ContestSerializer(contest).data
@ -107,7 +107,7 @@ class ContestRankAPI(APIView):
@check_contest_permission(check_type="ranks")
def get(self, request):
force_refresh = request.GET.get("force_refresh")
is_contest_admin = request.user.is_contest_admin(self.contest)
is_contest_admin = request.user.is_authenticated() and request.user.is_contest_admin(self.contest)
if self.contest.rule_type == ContestRuleType.OI:
serializer = OIContestRankSerializer
else:

View File

@ -51,7 +51,7 @@ class SubmissionAPI(APIView):
hide_id = False
if data.get("contest_id"):
try:
contest = Contest.objects.get(id=data["contest_id"])
contest = Contest.objects.get(id=data["contest_id"], visible=True)
except Contest.DoesNotExist:
return self.error("Contest doesn't exist.")
if contest.status == ContestStatus.CONTEST_ENDED: