Exemple #1
0
def display_news(page):
    lim = (-config.PAGE + page * config.PAGE, page * config.PAGE)
    result = database.get_articles(limit=lim)
    articles = [dict(title=row[0], slug=row[1],
                     content=row[2], posted=format_dt(row[3]))
                for row in result]
    return render_user_page('display_news.html',
                            articles=articles,
                            pg=page,
                            num_articles=database.get_num_articles())
Exemple #2
0
def display_admin_news(page):
    if user.is_admin():
        lim = (-config.PAGE + page * config.PAGE, page * config.PAGE)
        result = database.get_articles(limit=lim)
        articles = [dict(title=row[0], slug=row[1],
                         posted=format_dt(row[3]))
                    for row in result]
        return render_admin_page('admin_news.html',
                                 articles=articles,
                                 pg=page,
                                 num_articles=database.get_num_articles())
    else:
        return redirect(url_for('display_news'))