当前位置: 首页>>代码示例>>Python>>正文


Python Contest.getByAdmin方法代码示例

本文整理汇总了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), })
开发者ID:Mr-Phoebe,项目名称:BOJ-V2,代码行数:31,代码来源:views.py

示例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), })
开发者ID:Mr-Phoebe,项目名称:BOJ-V2,代码行数:47,代码来源:views.py


注:本文中的Contest.models.Contest.getByAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。