Mercurial > farol > farol
diff farol/producttree.py @ 84:cc836f9e869e
Allow deletion of Products
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Thu, 09 Oct 2014 14:26:59 +0200 |
parents | 2ecf13200e87 |
children | b6a48669edb8 |
line wrap: on
line diff
--- a/farol/producttree.py Thu Oct 09 14:26:33 2014 +0200 +++ b/farol/producttree.py Thu Oct 09 14:26:59 2014 +0200 @@ -213,6 +213,22 @@ ptree.addProduct(product) return redirect(url_for('.view')) +@producttree.route('/product/<productid>/del', methods=['POST']) +@document_required +@producttree_required +def del_product(productid): + cvrf = get_current() + ptree = cvrf._producttree + try: + product = cvrf.getProductForID(productid) + except KeyError: + abort(404) + product.unlink() + ptree._products.remove(product) + del product + return redirect(url_for('.view')) + + @producttree.route('/relationship/<int:index>/edit', methods=['GET', 'POST']) @document_required @producttree_required