Exemplo n.º 1
0
 def patch(self, id_):
     contest = Contest.get_by_id(id_)
     if contest is None:
         raise NotFound()
     args = contest_parser.parse_args()
     problem_list = args['problem_list']
     for problem_id in problem_list:
         problem = Problem.get_by_id(problem_id)
         if not problem:
             raise NotFound('problem {} not found'.format(problem_id))
     contest.modify(**contest_parser.parse_args())
     return {'message': 'modify success'}
Exemplo n.º 2
0
 def patch(self, id_):
     solution = Solution.get_by_id(id_)
     if solution is None:
         raise NotFound()
     status = modify_solution_parser.parse_args()['status']
     solution.modify(
         status='{} modify status to {}'.format(g.user.id, status))
Exemplo n.º 3
0
 def post(self):
     args = contest_parser.parse_args()
     problem_list = args['problem_list']
     for problem_id in problem_list:
         problem = Problem.get_by_id(problem_id)
         if not problem:
             raise NotFound('problem {} not found'.format(problem_id))
     Contest.modify(**contest_parser.parse_args())
     return {'message': 'create success'}, 201
Exemplo n.º 4
0
 def patch(self, id_):
     user = User.get_by_id(id_)
     if user is None:
         raise NotFound()
     args = modify_user_parser.parse_args()
     if args.get('password'):
         if user.check_password(args.get('old_password', '')) is False:
             raise AuthFailed('old password wrong')
     user.modify(**modify_user_parser.parse_args())
     return {'message': 'modify success'}
Exemplo n.º 5
0
 def post(self, id_):
     solution = Solution.get_by_id(id_)
     if solution is None:
         raise NotFound()
     if solution.status_canonical != 'OTHER' and g.user.permission != -1:
         raise Forbidden()
     problem = Problem.get_by_id(solution.problem_id)
     old_language = Language.search(oj=problem.remote_oj,
                                    value=solution.language)['data'][0].key
     solution.modify(status='Local info: Start rejudge')
     async_submit_code(solution.id, solution.problem_id, old_language,
                       solution.code)
     return {'message': 'create rejudge success'}, 201
Exemplo n.º 6
0
def handle_404():
    return NotFound()
Exemplo n.º 7
0
 def get(self, id_):
     user = User.get_by_id(id_)
     if user is None:
         raise NotFound()
     return user
Exemplo n.º 8
0
 def get(self, id_):
     solution = Solution.get_by_id(id_)
     if solution is None:
         raise NotFound()
     return solution
Exemplo n.º 9
0
 def get(self, id_):
     problem = Problem.get_by_id(id_)
     if problem is None:
         raise NotFound()
     return problem
Exemplo n.º 10
0
 def delete(self, id_):
     problem = Problem.get_by_id(id_)
     if not problem:
         raise NotFound()
     problem.delete()
     return {'message': 'delete success'}, 204
Exemplo n.º 11
0
 def patch(self, id_):
     problem = Problem.get_by_id(id_)
     if not problem:
         raise NotFound()
     problem.modify(**modify_problem_parser.parse_args())
     return {'message': 'modify success'}
Exemplo n.º 12
0
 def get(self, id_):
     contest = Contest.get_by_id(id_)
     if contest is None:
         raise NotFound()
     return contest