def problem_view_handler(problem_id):
try:
problem_id = int(problem_id)
except ValueError:
bottle.abort(404, 'Problem not found.')
try:
problem = model.get_public_problem(problem_id=problem_id)
except KeyError:
bottle.abort(404, 'Problem not found.')
owner = model.get_user(problem['owner'])
problem_spec = model.load_blob(problem['problem_spec_hash'])
snapshot_time, ranked_solutions = model.get_last_problem_ranking_snapshot(
problem_id=problem_id, public_only=True)
handler_util.inject_ranks_to_ranked_solutions(ranked_solutions)
template_dict = {
'problem': problem,
'problem_spec': problem_spec,
'owner': owner,
'ranked_solutions': ranked_solutions,
'snapshot_time': snapshot_time,
}
return handler_util.render('problem_view.html', template_dict)
评论列表
文章目录