本文整理匯總了Python中Contest.models.Contest.hasPriv方法的典型用法代碼示例。如果您正苦於以下問題:Python Contest.hasPriv方法的具體用法?Python Contest.hasPriv怎麽用?Python Contest.hasPriv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Contest.models.Contest
的用法示例。
在下文中一共展示了Contest.hasPriv方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: listContestByPriv
# 需要導入模塊: from Contest.models import Contest [as 別名]
# 或者: from Contest.models.Contest import hasPriv [as 別名]
def listContestByPriv(request, ccId, pageId='1'):
"""
view used to list all contest a user can manage, course_class restricted
"""
try:
u = User.getSessionUser(request.session)
if not u:
messages.info(request, u'請先登錄')
return render(request, 'newtpl/contest/contestListByPriv.html')
cc = CourseClass.getById(ccId)
if not Contest.hasPriv(cc, u):
raise Exception(Const.NOT_PVLG)
contestList = Contest.getByCourseClass(cc)
now = datetime.now()
for c in contestList:
c.course_class_name = unicode(c.course_class.getFullName())
c.title = unicode(c.contest_title)
if c.start_time+timedelta(minutes=c.length)<now:
c.status = 'ended'
elif c.start_time > now:
c.status = 'scheduled'
else:
c.status = 'running'
paginator = Paginator(contestList, Const.CONTEST_PER_PAGE)
pageId = min(max(int(pageId), 1), paginator.num_pages)
return render(request, 'newtpl/contest/contestListByPriv.html',
{'contest_list': paginator.page(pageId), 'course_class': cc,
'tpl':{'has_priv': True, 'nav_act':'contest',}})
except Exception as e:
return render(request, Const.ERROR_PAGE, {'errmsg': unicode(e), })
示例2: showContestNotice
# 需要導入模塊: from Contest.models import Contest [as 別名]
# 或者: from Contest.models.Contest import hasPriv [as 別名]
def showContestNotice(request, cId, cnId):
try:
u = User.getSessionUser(request.session)
if not u:
raise Exception(Const.NOT_LOGGED_IN)
c = Contest.getById(cId)
cn = ContestNotice.getById(cnId)
c.canEnterContest(u)
return render(request, 'newtpl/contest/showContestNotice.html',
{'cid': cId, 'contest_notice': cn,
'tpl': {'has_priv': Contest.hasPriv(c.course_class, u), 'sp': True, 'nav_act':'contest',}})
except Exception as e:
return render(request, Const.ERROR_PAGE, {'errmsg': unicode(e), })
示例3: showContest
# 需要導入模塊: from Contest.models import Contest [as 別名]
# 或者: from Contest.models.Contest import hasPriv [as 別名]
def showContest(request, cId):
try:
u = User.getSessionUser(request.session)
if not u:
raise Err(request, 'not login')
c = Contest.getById(cId)
cn = c.getContestNotice()
try:
c.canEnterContest(u)
except:
raise Err(request, 'no priv')
c.course_class_name = unicode(c.course_class.getFullName())
c.description = unicode(c.contest_description)
c.title = unicode(c.contest_title)
now = datetime.now()
c.time_passed = min(max(int((now-c.start_time).total_seconds())/60, 0), c.length)
c.time_passed_percent = 100*c.time_passed/c.length
c.time_left = c.length-c.time_passed
if c.start_time+timedelta(minutes=c.length)<now:
c.status = 'ended'
elif c.start_time > now:
c.status = 'scheduled'
else:
c.status = 'running'
priv = Contest.hasPriv(c.course_class, u)
problemList = c.getContestProblem()
for cp, cp_res, cp_user_res in zip(problemList, getContestResult(c=c), getContestUserResult(c=c, u=u)):
cp.index = cp.problem_index
cp.title = unicode(cp.problem_title)
cp.tlim = cp.problem.prob_time
cp.mlim = cp.problem.prob_memory
cp.ac = cp_res['ac_cnt']
cp.sub = cp_res['sub_cnt']
cp.ratio = cp_res['ac_ratio']
cp.user_res = cp_user_res
return render(request, 'newtpl/contest/showContest.html',
{'contest': c, 'problem_list': problemList, 'contest_notice_list':cn,'ccid': c.course_class.id, 'tpl':{'has_priv': priv, 'nav_act':'contest',}})
except Exception as e:
return render(request, Err.ERROR_PAGE, {'errmsg': unicode(e), })
示例4: _showContest
# 需要導入模塊: from Contest.models import Contest [as 別名]
# 或者: from Contest.models.Contest import hasPriv [as 別名]
def _showContest(request, cId):
cId = int(cId)
try:
u = User.getSessionUser(request.session)
if not u:
raise Exception(u'請先登錄')
c = Contest.getById(cId)
c.canEnterContest(u)
#cc = c.course_class
c.course_class_name = unicode(c.course_class.getFullName())
c.description = unicode(c.contest_description)
c.title = unicode(c.contest_title)
now = datetime.now()
if c.start_time+timedelta(minutes=c.length) < now:
c.status = 'ended'
elif c.start_time > now:
c.status = 'scheduled'
else:
c.status = 'running'
c.time_passed = min(max(int((now-c.start_time).total_seconds())/60, 0), c.length)
c.time_passed_percent = 100*c.time_passed/c.length
c.time_left = c.length-c.time_passed
cn = c.getContestNotice()
if c.status != 'scheduled' or c.canUpdateContest(u):
problemList = c.getContestProblem()
for cp in problemList:
cp.index = cp.problem_index
cp.title = unicode(cp.problem_title)
cp.tlim = cp.problem.prob_time
cp.mlim = cp.problem.prob_memory
return render(request, 'newtpl/contest/showContest.html',
{'contest': c, 'problem_list': problemList, 'contest_notice_list': cn, 'ccid': c.course_class.id,
'tpl':{'has_priv': Contest.hasPriv(c.course_class, u),}})
except Exception as e:
return render(request, Const.ERROR_PAGE, {'errmsg':unicode(e),})
示例5: showBoardByDynamicScore
# 需要導入模塊: from Contest.models import Contest [as 別名]
# 或者: from Contest.models.Contest import hasPriv [as 別名]
def showBoardByDynamicScore(request, cId):
logger.info(str(request).replace("\n","\t"))
try:
u = User.getSessionUser(request.session)
if not u:
raise Err(request, 'not login')
try:
c = Contest.getById(cId)
except:
raise Err(request, 'no resource')
try:
c.canEnterContest(u)
except:
raise Err(request, 'no priv')
return render(request,"newtpl/statistic/board_dynamic_score.html", {'contest': c, 'tpl': {'has_priv': Contest.hasPriv(c.course_class, u)}})
except Exception as e:
logger.error(str(e).replace("\n","\t"))
return render(request, Err.ERROR_PAGE)