Example #1
0
 def get(self, request):
     id = request.GET.get("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)
     except Contest.DoesNotExist:
         return self.error("Contest does not exist")
     data = ContestSerializer(contest).data
     data["now"] = datetime2str(now())
     return self.success(data)
Example #2
0
 def get(self, request):
     id = request.GET.get("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)
     except Contest.DoesNotExist:
         return self.error("Contest does not exist")
     data = ContestSerializer(contest).data
     data["now"] = datetime2str(now())
     courses = contest.course_set.all().order_by("-s_year")
     data["course"] = CourseSerializer(courses, many=True).data
     return self.success(data)