Пример #1
0
def undo(id):
    note = Note.get_or_404(id=id, author=current_user)

    try:
        note.revert()

    except note.VersionDoesNotExist:
        pass

    return redirect(url_for('.list'))
Пример #2
0
def edit(id):
    note = Note.get_or_404(id=id, author=current_user)

    if request.method == 'GET':
        return render_template('notes/edit.html', note=note)

    note.update(request.form['content'])

    existing_tags = set([tag.name for tag in note.tags])

    submitted_tags = set(
        [tag.strip() for tag in request.form.get('tags', '').split(',')])

    for tag in (submitted_tags - existing_tags):
        note.add_tag(tag)

    for tag in (existing_tags - submitted_tags):
        note.remove_tag(tag)

    return redirect(url_for('.list'))