Exemplo n.º 1
0
def index():
    u = current_user()
    board_id = request.args.get('board', '0')
    if board_id == '0':
        blogs = Blog.all()
    else:
        blogs = Blog.find_all(board_id=board_id)

    # blogs.reverse()
    blogs = sorted(blogs, key=lambda b: b.updated_time, reverse=True)
    page_index = 15
    page = request.args.get('page', 1)
    page_id = int(page)
    pages_list, page_max = page_cal(page_id, blogs, page_index)
    blogs = blogs[((page_id - 1) * page_index):(page_id * page_index)]

    boards = Board.all()
    return render_template('routes_blog/blog_index.html',
                           blogs=blogs,
                           u=u,
                           v=u,
                           boards=boards,
                           board_id=board_id,
                           pages_list=pages_list,
                           page_max=page_max)
Exemplo n.º 2
0
def user_profile():
    user_id = request.args['user_id']
    if user_id == '':
        return redirect(url_for('routes_user.login_view'))
    else:
        v = User.find(user_id)
        u = current_user()

        blogs1 = Blog.find_all(user_id=v.id)
        blogs1.reverse()

        blogs2 = blog_comment_recent(v)
        return render_template('routes_user/user_profile.html',
                               u=u,
                               v=v,
                               blogs1=blogs1[:5],
                               blogs2=blogs2[:5])
Exemplo n.º 3
0
def blog_index():
    blogs = Blog.find_all()
    return render_template('blog/blog_index.html', blogs=blogs)