Esempio n. 1
0
def Get(id):
    record = db.Read_Record(id)
    if record == None:
        flash(r'### 提交记录R%d没找着! \n 可能是因为编号不对.' % id, 'error')
        return redirect('/status')

    if record[12]:
        end_time = datetime.datetime.strptime(
            db.Read_Contest(record[12])[4], '%Y-%m-%d %H:%M:%S')
        now_time = datetime.datetime.now()
        if now_time < end_time:
            if request.cookies['username'] != record[
                    11] and not modules.Current_User_Privilege(3):
                flash(r'这是比赛时的提交, 您无权查看', 'error')
                return modules.Page_Back()
    elif not db.Read_Problem(
            record[1])[9] and not modules.Current_User_Privilege(
                2) and record[11] != modules.Current_User():
        flash(r'该题目尚未公开, 您无权查看', 'error')
        return modules.Page_Back()

    result = json.loads(record[7])
    subtasks = result['subtasks']
    contest = db.Read_Contest(record[12]) if record[12] else None
    return render_template('record.html',
                           record=record,
                           subtasks=subtasks,
                           contest=contest)
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)
Esempio n. 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)