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


Python Contest.hasPriv方法代码示例

本文整理汇总了Python中Contest.models.Contest.hasPriv方法的典型用法代码示例。如果您正苦于以下问题:Python Contest.hasPriv方法的具体用法?Python Contest.hasPriv怎么用?Python Contest.hasPriv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contest.models.Contest的用法示例。


在下文中一共展示了Contest.hasPriv方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: listContestByPriv

# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import hasPriv [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), })
开发者ID:Mr-Phoebe,项目名称:BOJ-V2,代码行数:36,代码来源:views.py

示例2: showContestNotice

# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import hasPriv [as 别名]
def showContestNotice(request, cId, cnId):
    try:
        u = User.getSessionUser(request.session)
        if not u:
            raise Exception(Const.NOT_LOGGED_IN)
        
        c = Contest.getById(cId)
        cn = ContestNotice.getById(cnId)
        c.canEnterContest(u)
        return render(request, 'newtpl/contest/showContestNotice.html',
                      {'cid': cId, 'contest_notice': cn,
                       'tpl': {'has_priv': Contest.hasPriv(c.course_class, u), 'sp': True, 'nav_act':'contest',}})
    except Exception as e:
        return render(request, Const.ERROR_PAGE, {'errmsg': unicode(e), })
开发者ID:Mr-Phoebe,项目名称:BOJ-V2,代码行数:16,代码来源:views.py

示例3: showContest

# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import hasPriv [as 别名]
def showContest(request, cId):
    try:
        u = User.getSessionUser(request.session)
        if not u:
            raise Err(request, 'not login')
        
        c = Contest.getById(cId)
        cn = c.getContestNotice()
        try:
            c.canEnterContest(u)
        except:
            raise Err(request, 'no priv')

        c.course_class_name = unicode(c.course_class.getFullName())
        c.description = unicode(c.contest_description)
        c.title = unicode(c.contest_title)
        now = datetime.now()
        c.time_passed = min(max(int((now-c.start_time).total_seconds())/60, 0), c.length)
        c.time_passed_percent = 100*c.time_passed/c.length
        c.time_left = c.length-c.time_passed
        if c.start_time+timedelta(minutes=c.length)<now:
            c.status = 'ended'
        elif c.start_time > now:
            c.status = 'scheduled'
        else:
            c.status = 'running'
        priv = Contest.hasPriv(c.course_class, u)

        problemList = c.getContestProblem()
        for cp, cp_res, cp_user_res in zip(problemList, getContestResult(c=c), getContestUserResult(c=c, u=u)):
            cp.index = cp.problem_index
            cp.title = unicode(cp.problem_title)
            cp.tlim = cp.problem.prob_time
            cp.mlim = cp.problem.prob_memory
            cp.ac = cp_res['ac_cnt']
            cp.sub = cp_res['sub_cnt']
            cp.ratio = cp_res['ac_ratio']
            cp.user_res = cp_user_res
        return render(request, 'newtpl/contest/showContest.html',
                {'contest': c, 'problem_list': problemList, 'contest_notice_list':cn,'ccid': c.course_class.id, 'tpl':{'has_priv': priv, 'nav_act':'contest',}})
    except Exception as e:
        return render(request, Err.ERROR_PAGE, {'errmsg': unicode(e), })
开发者ID:YLAsce,项目名称:oj,代码行数:44,代码来源:views.py

示例4: _showContest

# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import hasPriv [as 别名]
def _showContest(request, cId):
    cId = int(cId)

    try:
        u = User.getSessionUser(request.session)
        if not u:
            raise Exception(u'请先登录')

        c = Contest.getById(cId)
        c.canEnterContest(u)
        #cc = c.course_class

        c.course_class_name = unicode(c.course_class.getFullName())
        c.description = unicode(c.contest_description)
        c.title = unicode(c.contest_title)
        now = datetime.now()
        if c.start_time+timedelta(minutes=c.length) < now:
            c.status = 'ended'
        elif c.start_time > now:
            c.status = 'scheduled'
        else:
            c.status = 'running'
        c.time_passed = min(max(int((now-c.start_time).total_seconds())/60, 0), c.length)
        c.time_passed_percent = 100*c.time_passed/c.length
        c.time_left = c.length-c.time_passed

        cn = c.getContestNotice()

        if c.status != 'scheduled' or c.canUpdateContest(u):
            problemList = c.getContestProblem()
            for cp in problemList:
                cp.index = cp.problem_index
                cp.title = unicode(cp.problem_title)
                cp.tlim = cp.problem.prob_time
                cp.mlim = cp.problem.prob_memory

        return render(request, 'newtpl/contest/showContest.html',
                {'contest': c, 'problem_list': problemList, 'contest_notice_list': cn, 'ccid': c.course_class.id,
                    'tpl':{'has_priv': Contest.hasPriv(c.course_class, u),}})
    except Exception as e:
        return render(request, Const.ERROR_PAGE, {'errmsg':unicode(e),})
开发者ID:Mr-Phoebe,项目名称:BOJ-V2,代码行数:43,代码来源:views.py

示例5: showBoardByDynamicScore

# 需要导入模块: from Contest.models import Contest [as 别名]
# 或者: from Contest.models.Contest import hasPriv [as 别名]
def showBoardByDynamicScore(request, cId):
    logger.info(str(request).replace("\n","\t"))
    try:
        u = User.getSessionUser(request.session)
        if not u:
            raise Err(request, 'not login')
        try:
            c = Contest.getById(cId)
        except:
            raise Err(request, 'no resource')

        try:
            c.canEnterContest(u)
        except:
            raise Err(request, 'no priv')

        return render(request,"newtpl/statistic/board_dynamic_score.html", {'contest': c, 'tpl': {'has_priv': Contest.hasPriv(c.course_class, u)}})
    except Exception as e:
        logger.error(str(e).replace("\n","\t"))
        return render(request, Err.ERROR_PAGE)
开发者ID:YLAsce,项目名称:oj,代码行数:22,代码来源:views.py


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