def add_entry(): form = entryForm() if form.validate_on_submit: if not session.get('logged_in'): abort(403) EntryAdd(form.title.data, form.body.data, session['user_id']) return redirect(url_for('index')), 201
def index(): form = entryForm() if not session.get('logged_in'): return render_template('index.html') else: entries = EntryGetByUserId(session['user_id']) return render_template('show_entries.html', entries=entries, form=form)
def edit_entry_form(id): entry = EntryGetById(id) if not session.get('logged_in') or session['user_id'] != entry.user_id: abort(404) form = entryForm() form.title.data = entry.title form.body.data = entry.body return render_template('edit.html', entry=entry, form=form)
def edit_entry(id): form = entryForm() if form.validate_on_submit: EntryEdit(id, form.title.data, form.body.data) return redirect(url_for('index')), 200