def get(self, *, tid: objectid.ObjectId, pid: document.convert_doc_id):
uid = self.user['_id'] if self.has_priv(builtin.PRIV_USER_PROFILE) else None
tdoc, pdoc = await asyncio.gather(contest.get(self.domain_id, tid),
problem.get(self.domain_id, pid, uid))
tsdoc, udoc = await asyncio.gather(
contest.get_status(self.domain_id, tdoc['doc_id'], self.user['_id']),
user.get_by_uid(tdoc['owner_uid']))
attended = tsdoc and tsdoc.get('attend') == 1
if not self.is_done(tdoc):
if not attended:
raise error.ContestNotAttendedError(tdoc['doc_id'])
if not self.is_live(tdoc):
raise error.ContestNotLiveError(tdoc['doc_id'])
if pid not in tdoc['pids']:
raise error.ProblemNotFoundError(self.domain_id, pid, tdoc['doc_id'])
path_components = self.build_path(
(self.translate('contest_main'), self.reverse_url('contest_main')),
(tdoc['title'], self.reverse_url('contest_detail', tid=tid)),
(pdoc['title'], None))
self.render('problem_detail.html', tdoc=tdoc, pdoc=pdoc, tsdoc=tsdoc, udoc=udoc,
attended=attended,
page_title=pdoc['title'], path_components=path_components)
评论列表
文章目录