本文整理汇总了Python中Contest.models.Contest.getByCourseClass方法的典型用法代码示例。如果您正苦于以下问题:Python Contest.getByCourseClass方法的具体用法?Python Contest.getByCourseClass怎么用?Python Contest.getByCourseClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contest.models.Contest
的用法示例。
在下文中一共展示了Contest.getByCourseClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listContestByPriv
# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import getByCourseClass [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), })