Exemplo n.º 1
0
def get_children(post_id, levels):
    if levels > 0:
    	result = database.get_posts(parent=post_id)
        return [dict(id=row[0], title=row[1], content=row[2],
                     author=row[3], posted=format_dt(row[4]),
                     locked=row[5],
                     children=get_children(row[0], (levels - 1)))
                for row in result]
    else:
        return None
Exemplo n.º 2
0
def display_threads(page):
    if user.is_logged_in():
        lim = (-config.PAGE + page * config.PAGE, page * config.PAGE)
        result = database.get_posts(limit=lim, parent=None)
        posts = [dict(id=row[0], title=row[1], content=row[2],
                      author=row[3], posted=format_dt(row[4]),
                      pinned=row[5])
                    for row in result]
        return render_user_page('forum.html',
                                posts=posts,
                                pg=page,
                                num_threads=database.get_num_posts())
    else:
        return redirect(url_for('display_news'))