本文整理匯總了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), })