# HG changeset patch # User BenoƮt Allard # Date 1412842344 -7200 # Node ID 727c01e8e3e9796474101e5fe10c326807c42f1b # Parent 42915aaa6888eb8e4c854d5164844c9d55954588 Allow deletion of Notes diff -r 42915aaa6888 -r 727c01e8e3e9 farol/document.py --- a/farol/document.py Thu Oct 09 10:11:35 2014 +0200 +++ b/farol/document.py Thu Oct 09 10:12:24 2014 +0200 @@ -213,6 +213,19 @@ get_current().addNote(note) return redirect(url_for('.view')) +@document.route('/note/del', methods=['POST']) +@document_required +def del_note(): + ordinal = int(request.form['ordinal']) + cvrf = get_current() + notes = cvrf._notes + note = cvrf.getNote(ordinal) + if note is None: + flash('Note not found', 'danger') + abort(404) + notes.remove(note) + return redirect(url_for('.view')) + @document.route('/reference//edit', methods=['GET', 'POST']) @document_required def edit_reference(index): diff -r 42915aaa6888 -r 727c01e8e3e9 farol/templates/document/view_note.j2 --- a/farol/templates/document/view_note.j2 Thu Oct 09 10:11:35 2014 +0200 +++ b/farol/templates/document/view_note.j2 Thu Oct 09 10:12:24 2014 +0200 @@ -24,7 +24,7 @@ -#} {% extends "base.j2" %} - +{% from "macros.j2" import delete_button %} {% block title %}{{ note._title }}{% endblock %} {% block content %} @@ -34,4 +34,5 @@ {% if note._audience %}

Audience: {{ note._audience }}

{% endif %}

{{ note._note | replace('\n', '
') }}

+
{{ delete_button(url_for('.del_note'), {'ordinal': note._ordinal}) }}
{% endblock %}