changeset 92:33d6fd9a5e12

Add deletion of Product Statuses
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 16:08:45 +0200
parents 6a61c02f2156
children 8e72f31d7392
files farol/templates/vulnerability/view_productstatus.j2 farol/vulnerability.py
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/farol/templates/vulnerability/view_productstatus.j2	Thu Oct 09 16:03:04 2014 +0200
+++ b/farol/templates/vulnerability/view_productstatus.j2	Thu Oct 09 16:08:45 2014 +0200
@@ -24,7 +24,7 @@
 -#}
 
 {% extends "vulnerability/base.j2" %}
-
+{% from "macros.j2" import delete_button %}
 {% block title %}{{ status.getTitle() }}{% endblock %}
 
 {% block i_content %}
@@ -37,4 +37,5 @@
     <li><a href="{{ url_for('producttree.view_product', productid=productid) }}">{{ cvrf.getProductForID(productid)._name }}</a></li>
   {% endfor %}
 </ul>
+<div class="pull-right">{{ delete_button(url_for('.del_status', ordinal=ordinal, index=index)) }}</div>
 {% endblock %}
--- a/farol/vulnerability.py	Thu Oct 09 16:03:04 2014 +0200
+++ b/farol/vulnerability.py	Thu Oct 09 16:08:45 2014 +0200
@@ -254,7 +254,6 @@
     get_vuln(ordinal).addProductStatus(status)
     return redirect(url_for('.view', ordinal=ordinal))
 
-
 @vulnerability.route('/<int:ordinal>/productstatus/<int:index>/edit', methods=['GET', 'POST'])
 @document_required
 def edit_status(ordinal, index):
@@ -271,6 +270,17 @@
         status.addProductID(productid)
     return redirect(url_for('.view', ordinal=ordinal))
 
+@vulnerability.route('/<int:ordinal>/productstatus/<int:index>/del', methods=['POST'])
+@document_required
+def del_status(ordinal, index):
+    statuses = get_vuln(ordinal)._productstatuses
+    if not ( 0 <= index < len(statuses)):
+        flash('Product Status not found', 'danger')
+        abort(404)
+
+    del statuses[index]
+    return redirect(url_for('.view', ordinal=ordinal))
+
 
 @vulnerability.route('/<int:ordinal>/threat/<int:index>')
 @document_required

http://farol.wald.intevation.org