changeset 88:521c0ec35338

Add deletion of Groups
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 15:37:51 +0200
parents e02724c84bae
children e558238cfdb2
files farol/producttree.py farol/templates/producttree/view.j2
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/farol/producttree.py	Thu Oct 09 15:16:30 2014 +0200
+++ b/farol/producttree.py	Thu Oct 09 15:37:51 2014 +0200
@@ -326,3 +326,18 @@
         group.addProductID(productid)
     get_current()._producttree.addGroup(group)
     return redirect(url_for('.view'))
+
+@producttree.route('/group/<groupid>/del', methods=['POST'])
+@document_required
+@producttree_required
+def del_group(groupid):
+    cvrf = get_current()
+    try:
+        group = get_current().getGroupForID(groupid)
+    except KeyError:
+        flash('Group not found', 'danger')
+        abort(404)
+
+    cvrf._producttree._groups.remove(group)
+    return redirect(url_for('.view'))
+
--- a/farol/templates/producttree/view.j2	Thu Oct 09 15:16:30 2014 +0200
+++ b/farol/templates/producttree/view.j2	Thu Oct 09 15:37:51 2014 +0200
@@ -84,7 +84,10 @@
 {% call panel(heading="Groups", badge=producttree._groups | length, title=4) %}
   {% for group in producttree._groups %}
     {% call panel() %}
-      <a href="{{ url_for('.edit_group', groupid=group._groupid) }}" class="pull-right">edit</a>
+      <div class="pull-right">
+        <a href="{{ url_for('.edit_group', groupid=group._groupid) }}"><span class="label label-default">edit</span></a>
+        {{ delete_button(url_for('.del_group', groupid=group._groupid)) }}
+      </div>
       <ul>
         {% for productid in group._productids %}
           {% with product = cvrf.getProductForID(productid) %}

http://farol.wald.intevation.org