def display_article(slug): result = database.get_article(slug) if result[0]: article = dict(title=result[1][0], content=result[1][1], posted=format_dt(result[1][2])) return render_user_page('display_article.html', article=article) else: abort(404)
def edit_article(slug): if request.method == 'POST' and user.is_admin(): result = database.update_article(slug, request.form['title'], request.form['content'], 0) if result[0]: flash('Post created.') return redirect(url_for('display_admin_news')) else: return render_admin_page('edit_article.html', error=result[1]) elif user.is_admin(): result = database.get_article(slug) if result[0]: article = dict(title=result[1][0], slug=slug, content=result[1][1], posted=result[1][2]) return render_admin_page('edit_article.html', article=article) else: return render_admin_page('edit_article.html', error=result[1]) else: return redirect(url_for('display_news'))