本文整理汇总了Python中Contest.models.Contest.getByAdmin方法的典型用法代码示例。如果您正苦于以下问题:Python Contest.getByAdmin方法的具体用法?Python Contest.getByAdmin怎么用?Python Contest.getByAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contest.models.Contest
的用法示例。
在下文中一共展示了Contest.getByAdmin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listContestByUserAndPriv
# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import getByAdmin [as 别名]
def listContestByUserAndPriv(request, pageId='1'):
"""
view used to list all contest a user can manage
"""
try:
u = User.getSessionUser(request.session)
if not u:
messages.info(request, u'请先登录')
return render(request, 'newtpl/contest/contestListByUserAndPriv.html')
contestList = Contest.getByAdmin(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/contestListByUserAndPriv.html', {
'contest_list': paginator.page(pageId), 'tpl':{'has_priv': True, 'sp': True, }})
except Exception as e:
return render(request, Const.ERROR_PAGE, {'errmsg': unicode(e), })
示例2: listContestByUser
# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import getByAdmin [as 别名]
def listContestByUser(request, pageId='1'):
"""
view used to list all contest a user can participate
"""
logger.info(str(request).replace("\n","\t"))
tpl = {'nav_act':'contest'}
try:
u = User.getSessionUser(request.session)
if not u:
messages.info(request, u'请先登录')
contestList = None
else:
now = datetime.now()
if u.priv == 'student':
contestList = Contest.getByStudent(u)
else:
contestList = Contest.getByAdmin(u)
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)
if contestList and contestList.count>0:
return render(request, 'newtpl/contest/contestListByUser.html', {
'contest_list': paginator.page(pageId), 'tpl':tpl})
else:
return render(request, 'newtpl/contest/contestListByUser.html', {
'tpl':tpl, 'err_msg_list': [
u'您暂时没有可以参加的测验。',
u'不如走出教室,呼吸一下新鲜空气,给家人打个电话,陪陪妹子?'
]})
except Exception as e:
return render(request, Const.ERROR_PAGE, {'errmsg': unicode(e), })