changeset 70:727c01e8e3e9

Allow deletion of Notes
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 10:12:24 +0200
parents 42915aaa6888
children 51825b0c4890
files farol/document.py farol/templates/document/view_note.j2
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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/<int:index>/edit', methods=['GET', 'POST'])
 @document_required
 def edit_reference(index):
--- 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 @@
 </div>
 {% if note._audience %}<p>Audience: <em>{{ note._audience }}</em></p>{% endif %}
 <p>{{ note._note | replace('\n', '<br>') }}</p>
+<div class="pull-right">{{ delete_button(url_for('.del_note'), {'ordinal': note._ordinal}) }}</div>
 {% endblock %}

http://farol.wald.intevation.org