本文整理汇总了Python中Contest.models.Contest.canTouchContest方法的典型用法代码示例。如果您正苦于以下问题:Python Contest.canTouchContest方法的具体用法?Python Contest.canTouchContest怎么用?Python Contest.canTouchContest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contest.models.Contest
的用法示例。
在下文中一共展示了Contest.canTouchContest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listContest
# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import canTouchContest [as 别名]
def listContest(request, ccId, pageId='1'):
"""
view used to list all contest a user can participate, course_class restricted
"""
try:
u = User.getSessionUser(request.session)
if not u:
messages.info(request, u'请先登录')
return render(request, 'newtpl/contest/contestList.html')
cc = CourseClass.getById(ccId)
Contest.canTouchContest(cc, u)
now = datetime.now()
contestList = Contest.getByCourseClass(cc)
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/contestList.html',
{'contest_list': paginator.page(pageId), 'course_class': cc, 'tpl':{'nav_act':'contest',}})
except Exception as e:
return render(request, Const.ERROR_PAGE, {'errmsg': unicode(e), })