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'}
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))
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
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'}
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
def handle_404(): return NotFound()
def get(self, id_): user = User.get_by_id(id_) if user is None: raise NotFound() return user
def get(self, id_): solution = Solution.get_by_id(id_) if solution is None: raise NotFound() return solution
def get(self, id_): problem = Problem.get_by_id(id_) if problem is None: raise NotFound() return problem
def delete(self, id_): problem = Problem.get_by_id(id_) if not problem: raise NotFound() problem.delete() return {'message': 'delete success'}, 204
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'}
def get(self, id_): contest = Contest.get_by_id(id_) if contest is None: raise NotFound() return contest