Exemplo 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)
Exemplo 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())
Exemplo 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)
Exemplo n.º 4
0
def article(article_id):
    article = Article.query.filter_by(id=article_id).first()
    if not article:
        return show_error("找不到文章", url_for('index'))

    comments = Comment.query.filter_by(article_id=article_id)
    comments_num = comments.count()

    def make_url(page, other):
        return url_for("article",
                       article_id=article_id) + "?" + parse.urlencode(
                           {"page": page})

    sorter = Paginate(comments,
                      make_url=make_url,
                      cur_page=request.args.get("page"),
                      edge_display_num=3,
                      per_page=10)

    return render_template("article.html",
                           tool=Tools,
                           article=article,
                           comment_num=comments_num,
                           sorter=sorter,
                           tab="discussion")
Exemplo n.º 5
0
def contest_list():
    query = Contest.query.order_by(db.desc(Contest.start_time))

    def make_url(page, other):
        return url_for("contest_list") + "?" + urlencode({"page": page})

    sorter = Paginate(query, make_url=make_url, cur_page=request.args.get("page"), edge_display_num=3, per_page=10)
    return render_template("contest_list.html", tool=Tools, sorter=sorter, now=time.time())
Exemplo n.º 6
0
def info():
    query = User.query.order_by(db.desc(User.ac_num))
    notice = Notice.query.all()
    ranker = Paginate(query, cur_page=1, per_page=10)
    return render_template("info.html",
                           tool=Tools,
                           tab="info",
                           notice=notice,
                           ranker=ranker)
Exemplo n.º 7
0
def discussion():
    query = Article.query.order_by(Article.sort_time.desc())

    def make_url(page, other):
        return url_for("discussion") + "?" + urlencode({"page": page})

    sorter = Paginate(query,
                      make_url=make_url,
                      cur_page=request.args.get("page"),
                      edge_display_num=3,
                      per_page=10)
    return render_template("discussion.html",
                           tool=Tools,
                           tab="discussion",
                           sorter=sorter)
Exemplo n.º 8
0
Arquivo: user.py Projeto: siteoj/SYOJ
def ranklist():
    query = User.query.order_by(db.desc(User.ac_num))

    def make_url(page, other):
        return url_for("ranklist") + "?" + Tools.url_encode({"page": page})

    sorter = Paginate(query,
                      make_url=make_url,
                      cur_page=request.args.get("page"),
                      edge_display_num=3,
                      per_page=50)

    return render_template("ranklist.html",
                           tool=Tools,
                           sorter=sorter,
                           tab="ranklist")
Exemplo n.º 9
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())
Exemplo n.º 10
0
def index():
    query = User.query.order_by(db.desc(User.ac_num))
    ranker = Paginate(query, cur_page=1,  per_page=10)
    return render_template("index.html", tool=Tools, tab="index", ranker=ranker)