mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 08:32:08 +00:00
check is id
This commit is contained in:
parent
7e4132bed1
commit
6f8e68846c
@ -8,7 +8,7 @@ from django.core.cache import cache
|
||||
from problem.models import Problem
|
||||
from utils.api import APIView, validate_serializer
|
||||
from utils.constants import CacheKey
|
||||
from utils.shortcuts import datetime2str
|
||||
from utils.shortcuts import datetime2str, check_is_id
|
||||
from account.models import AdminType
|
||||
from account.decorators import login_required, check_contest_permission
|
||||
|
||||
@ -35,7 +35,7 @@ class ContestAnnouncementListAPI(APIView):
|
||||
class ContestAPI(APIView):
|
||||
def get(self, request):
|
||||
id = request.GET.get("id")
|
||||
if not id:
|
||||
if not id or not check_is_id(id):
|
||||
return self.error("Invalid parameter, id is required")
|
||||
try:
|
||||
contest = Contest.objects.get(id=id, visible=True)
|
||||
|
@ -85,3 +85,10 @@ def get_env(name, default=""):
|
||||
|
||||
def DRAMATIQ_WORKER_ARGS(time_limit=3600_000, max_retries=0, max_age=7200_000):
|
||||
return {"max_retries": max_retries, "time_limit": time_limit, "max_age": max_age}
|
||||
|
||||
|
||||
def check_is_id(value):
|
||||
try:
|
||||
return int(value) > 0
|
||||
except Exception as e:
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user