Beispiel #1
0
def display_page(slug):
    result = database.get_page(slug)
    if result[0]:
        page = dict(title=result[1][0], content=result[1][1])
        return render_user_page('display_page.html',
                                page=page)
    else:
        abort(404)
Beispiel #2
0
def edit_page(slug):
    if request.method == 'POST' and user.is_admin():
        result = database.update_page(slug,
                                      request.form['title'],
                                      request.form['content'])
        if result[0]:
            flash('Page created.')
            return redirect(url_for('display_admin_pages'))
        else:
            return render_admin_page('edit_page.html', error=result[1])
    elif user.is_admin():
        result = database.get_page(slug)
        if result[0]:
            page = dict(title=result[1][0], slug=slug,
                        content=result[1][1])
            return render_admin_page('edit_page.html', page=page)
        else:
            return render_admin_page('edit_page.html', error=result[1])
    else:
        return redirect(url_for('display_news'))