Esempio n. 1
0
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
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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