mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
finish interface for get similar check result
This commit is contained in:
parent
7d0d1879ed
commit
4c38633826
@ -106,3 +106,9 @@ class ACMContesHelperSerializer(serializers.Serializer):
|
|||||||
problem_id = serializers.CharField()
|
problem_id = serializers.CharField()
|
||||||
rank_id = serializers.IntegerField()
|
rank_id = serializers.IntegerField()
|
||||||
checked = serializers.BooleanField()
|
checked = serializers.BooleanField()
|
||||||
|
|
||||||
|
|
||||||
|
class ContestSimilarResultSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Contest
|
||||||
|
fields = ["similarity_check_result"]
|
||||||
|
|||||||
@ -63,6 +63,8 @@ class ContestAPITest(APITestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
user = self.create_admin()
|
user = self.create_admin()
|
||||||
self.contest = Contest.objects.create(created_by=user, **DEFAULT_CONTEST_DATA)
|
self.contest = Contest.objects.create(created_by=user, **DEFAULT_CONTEST_DATA)
|
||||||
|
self.contest.similarity_check_result = ["aaa", "bbb", "ccc"]
|
||||||
|
self.contest.save()
|
||||||
self.url = self.reverse("contest_api") + "?id=" + str(self.contest.id)
|
self.url = self.reverse("contest_api") + "?id=" + str(self.contest.id)
|
||||||
|
|
||||||
def test_get_contest_list(self):
|
def test_get_contest_list(self):
|
||||||
@ -97,6 +99,12 @@ class ContestAPITest(APITestCase):
|
|||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertSuccess(resp)
|
self.assertSuccess(resp)
|
||||||
|
|
||||||
|
def test_regular_user_get_similiar(self):
|
||||||
|
self.create_user("test", "test123")
|
||||||
|
url = self.reverse("contest_get_similar_api")
|
||||||
|
resp = self.client.get(url + "?contest_id=" + str(self.contest.id))
|
||||||
|
self.assertEqual(resp.data["data"]["similarity_check_result"], ["aaa", "bbb", "ccc"])
|
||||||
|
|
||||||
|
|
||||||
class ContestAnnouncementAdminAPITest(APITestCase):
|
class ContestAnnouncementAdminAPITest(APITestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@ -17,6 +17,7 @@ from ..models import ContestAnnouncement, Contest, OIContestRank, ACMContestRank
|
|||||||
from ..serializers import ContestAnnouncementSerializer
|
from ..serializers import ContestAnnouncementSerializer
|
||||||
from ..serializers import ContestSerializer, ContestPasswordVerifySerializer
|
from ..serializers import ContestSerializer, ContestPasswordVerifySerializer
|
||||||
from ..serializers import OIContestRankSerializer, ACMContestRankSerializer
|
from ..serializers import OIContestRankSerializer, ACMContestRankSerializer
|
||||||
|
from ..serializers import ContestSimilarResultSerializer
|
||||||
|
|
||||||
|
|
||||||
class ContestAnnouncementListAPI(APIView):
|
class ContestAnnouncementListAPI(APIView):
|
||||||
@ -189,4 +190,6 @@ class ContestRankAPI(APIView):
|
|||||||
|
|
||||||
class ContestGetSimilarAPI(APIView):
|
class ContestGetSimilarAPI(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
return self.success()
|
contest_id = request.GET.get("contest_id")
|
||||||
|
contest = Contest.objects.get(id=contest_id, visible=True)
|
||||||
|
return self.success(ContestSimilarResultSerializer(contest).data)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user