Ejemplo n.º 1
0
def index():
    query = Problem.query.order_by(Problem.time_limit)
    problem_title = request.args.get("problem_title")
    notice = Notice.query.all()
    if request.args.get("problem_title"):
        query = query.filter(
            or_(Problem.title.like((u"%" + problem_title + u"%")),
                Problem.tags.like((u"%" + problem_title + u"%")),
                Problem.id.like((u"%" + problem_title + u"%"))))
    else:
        problem_title = ''

    def make_url(page, other):
        other["page"] = page
        return url_for("problem_set") + "?" + parse.urlencode(other)

    sorter = Paginate(query,
                      make_url=make_url,
                      other={"problem_title": problem_title},
                      cur_page=request.args.get("page"),
                      edge_display_num=50,
                      per_page=50)
    return render_template("index.html",
                           tool=Tools,
                           tab="home",
                           sorter=sorter,
                           problems=sorter.get(),
                           notice=notice)
Ejemplo n.º 2
0
def problem_set():
    query = Problem.query
    problem_title = request.args.get("problem_title")

    if request.args.get("problem_title"):
        query = query.filter(Problem.title.like((u"%" + problem_title + u"%")))
    else:
        problem_title = ''

    def make_url(page, other):
        other["page"] = page
        return url_for("problem_set") + "?" + urlencode(other)

    sorter = Paginate(query,
                      make_url=make_url,
                      other={"problem_title": problem_title},
                      cur_page=request.args.get("page"),
                      edge_display_num=50,
                      per_page=50)

    return render_template("problem_set.html",
                           tool=Tools,
                           tab="problem_set",
                           sorter=sorter,
                           problems=sorter.get())
Ejemplo n.º 3
0
def judge_state():
    query = JudgeState.query.order_by(db.desc(JudgeState.id))
    nickname = request.args.get("submitter")
    problem_id = request.args.get("problem_id")
    if request.args.get("submitter"):
        submitter = User.query.filter_by(nickname=nickname).first()
        if submitter:
            submitter_id = submitter.id
        else:
            submitter_id = 0
        query = query.filter_by(user_id=submitter_id)
    if request.args.get("problem_id"):
        query = query.filter_by(problem_id=int(problem_id))

    def make_url(page, other):
        other["page"] = page
        return url_for("judge_state") + "?" + urlencode(other)

    if not nickname:
        nickname = ""
    if not problem_id:
        problem_id = ""
    sorter = Paginate(query, make_url=make_url, other={"submitter": nickname, "problem_id": problem_id},
                      cur_page=request.args.get("page"), edge_display_num=3, per_page=10)

    return render_template("judge_state.html", user=User.get_cur_user(), judges=sorter.get(), tab="judge",
                           submitter=nickname, problem_id=problem_id, sorter=sorter, encode=urlencode, tool=Tools)
Ejemplo n.º 4
0
def problem_set():
    query = Problem.query
    problem_title = request.args.get("problem_title")
    
    if request.args.get("problem_title"):
        query = query.filter(Problem.title.like((u"%" + problem_title + u"%")))
    else:
        problem_title = ''

    def make_url(page, other):
        other["page"] = page
        return url_for("problem_set") + "?" + urlencode(other)
        
    sorter = Paginate(query, make_url=make_url, other={"problem_title": problem_title},
            cur_page=request.args.get("page"), edge_display_num=50, per_page=50)
            
    return render_template("problem_set.html", tool=Tools, tab="problem_set", sorter=sorter, problems=sorter.get())