changeset 74:80cd8f65e72b

Add deletion of Acknowledgments
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 11:17:19 +0200
parents 88adf067cae1
children 95c79e518204
files farol/document.py farol/templates/document/view_acknowledgment.j2
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/farol/document.py	Thu Oct 09 11:14:50 2014 +0200
+++ b/farol/document.py	Thu Oct 09 11:17:19 2014 +0200
@@ -292,3 +292,13 @@
     ack = create_acknowledgment_from_request()
     get_current().addAcknowledgment(ack)
     return redirect(url_for('.view'))
+
+@document.route('/acknowledgment/<int:index>/del', methods=['POST'])
+@document_required
+def del_acknowledgment(index):
+    acks = get_current()._acknowledgments
+    if not( 0 <= index < len(acks)):
+        flash('Acknowledgment not found', 'danger')
+        abort(404)
+    del acks[index]
+    return redirect(url_for('.view'))
--- a/farol/templates/document/view_acknowledgment.j2	Thu Oct 09 11:14:50 2014 +0200
+++ b/farol/templates/document/view_acknowledgment.j2	Thu Oct 09 11:17:19 2014 +0200
@@ -24,7 +24,7 @@
 -#}
 
 {% extends "base.j2" %}
-{% from "macros.j2" import label_value %}
+{% from "macros.j2" import label_value, delete_button %}
 {% block title %}{{ acknowledgment.getTitle() }}{% endblock %}
 
 {% block content %}
@@ -36,4 +36,5 @@
   {{ label_value('Description', acknowledgment._description or '') }}
   {{ label_value('URL', (acknowledgment._url or '') | urlize) }}
 </div>
+<div class="pull-right">{{ delete_button(url_for('.del_acknowledgment', index=index)) }}</div>
 {% endblock %}

http://farol.wald.intevation.org