コード例 #1
0
def Submissions_My(contest_id):
    try:
        page = int(request.args['page'])
    except:
        page = 1

    if not modules.Is_Loggedin():
        flash(r'请先登录', 'error')
        return modules.Page_Back()

    contest = db.Read_Contest(contest_id)
    if contest == None:
        flash(r'不存在的比赛', 'error')
        return modules.Page_Back()

    limitations = request.args.to_dict()
    limitations['contest_id'] = contest_id
    limitations['username'] = modules.Current_User()
    submissions = db.Read_Submissions(limitations)
    status_show, total_page = modules.Page_Split(submissions, page,
                                                 status_per_page,
                                                 lambda status: True)
    return render_template('status.html',
                           statuslist=status_show,
                           total_page=total_page,
                           current_page=page,
                           contest=contest,
                           contest_id=contest_id,
                           my=True)
コード例 #2
0
def Submissions_All(contest_id):
    try:
        page = int(request.args['page'])
    except:
        page = 1

    contest = db.Read_Contest(contest_id)
    if contest == None:
        flash(r'不存在的比赛', 'error')
        return modules.Page_Back()

    limitations = request.args.to_dict()
    limitations['contest_id'] = contest_id
    submissions = db.Read_Submissions(limitations)

    status_show, total_page = modules.Page_Split(submissions, page,
                                                 status_per_page,
                                                 lambda status: True)

    return render_template('status.html',
                           statuslist=status_show,
                           total_page=total_page,
                           current_page=page,
                           contest=contest,
                           contest_id=contest_id,
                           my=False)
コード例 #3
0
def Run():
    args = dict(request.args)

    if args.get('contest_id') == None: args['contest_id'] = 0
    page = int(request.args['page']) if 'page' in args else 1

    statuslist = db.Read_Submissions(args)

    status_show, total_page = modules.Page_Split(
        statuslist, page, status_per_page,
        lambda status: status[11] == modules.Current_User() or modules.
        Current_User_Privilege(2) or db.Read_Problem(status[1])[9])

    if args['contest_id'] == 0:
        return render_template('status.html',
                               statuslist=status_show,
                               total_page=total_page,
                               current_page=page,
                               contest=None,
                               contest_id=0)
    else:
        contest_id = args['contest_id']
        contest = db.Read_Contest(contest_id)
        return render_template('status.html',
                               statuslist=status_show,
                               total_page=total_page,
                               current_page=page,
                               contest=contest,
                               contest_id=contest_id)
コード例 #4
0
def Run(problem_id):
    problem = db.Read_Problem(problem_id)

    args = request.args
    page = int(args['page']) if 'page' in args else 1
    order = args['order'] if 'order' in args else 'time_usage'

    submissions = db.Read_Submissions({
        'problem_id': problem_id,
        'status': 10
    }, order)
    submission_shown = []
    counted = {}
    for submission in submissions:
        if counted.get(submission[11]) != None: continue
        counted[submission[11]] = 1
        submission_shown.append(submission)

    submission_shown_inpage, total_page = modules.Page_Split(
        submission_shown, page, status_per_page, lambda status: True)

    return render_template('problem_ranklist.html',
                           problem=problem,
                           submissions=submission_shown_inpage,
                           total_page=total_page,
                           current_page=page)
コード例 #5
0
ファイル: problemlist.py プロジェクト: interestingLSY/intOJ
def Run():
    page = int(request.args['page']) if 'page' in request.args else 1

    problemlist = db.Read_Problemlist()

    can_view_hidden = modules.Current_User_Privilege(2)
    problem_show, total_page = modules.Page_Split(
        problemlist, page, problem_per_page,
        lambda problem: problem[9] or can_view_hidden)

    submitted_status = {}
    if modules.Is_Loggedin():

        def Better(new, before):
            if new[4] != before[4]: return new[4] > before[4]
            if new[5] != before[5]: return new[5] > before[5]
            if new[8] != before[8]: return new[8] < before[8]
            if new[9] != before[9]: return new[9] < before[9]
            if new[0] != before[0]: return new[0] > before[0]
            return False

        submissions = db.Read_Submissions(
            {'username': request.cookies['username']}, 'id ASC')
        for submission in submissions:
            problem_id = submission[1]
            if problem_id not in submitted_status or Better(
                    submission, submitted_status[problem_id]):
                submitted_status[problem_id] = submission

    return render_template('problemlist.html',
                           problemlist=problem_show,
                           submitted_status=submitted_status,
                           current_page=page,
                           total_page=total_page)