Exemplo n.º 1
0
def list(page):
    res = paginate(db.session.query(Post).order_by(Post.id.desc()), page)

    if len(res['posts']) == 0:
        flash("We don't have that many posts.", 'error')
        abort(404)

    return render_template('posts/list.html', page=page, **res)
Exemplo n.º 2
0
def show(id, page):
    tag = get_tag(id)
    post_ids = map(lambda x: x.id, tag.posts)
    res = paginate(db.session.query(Post).\
            filter(Post.id.in_(post_ids)).order_by(Post.id.desc()), page)

    if page != 1 and len(res['posts']) == 0:
        flash("This tag doesn't have that many posts.", 'error')
        abort(404)

    return render_template('tags/show.html', tag=tag, page=page, **res)