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