Mercurial > farol
changeset 135:5e9237340630
Add server-side check before deleting a producttree element.
author | BenoƮt Allard <benoit.allard@greenbone.net> |
---|---|
date | Fri, 24 Oct 2014 14:55:00 +0200 (2014-10-24) |
parents | 50f15280dfee |
children | 64a6e69d54fc |
files | farol/producttree.py |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/farol/producttree.py Fri Oct 24 13:01:57 2014 +0200 +++ b/farol/producttree.py Fri Oct 24 14:55:00 2014 +0200 @@ -62,7 +62,9 @@ @producttree.route('/delete', methods=['POST']) @producttree_required def delete(): - # XXX: We should first check if no PID and GID is used ... + if not cvrf.isProductTreeOrphan(): + flash('Not deleting the Product Tree, some Products are mentionned in the document', 'danger') + return redirect(url_for('.view')) get_current()._producttree = None return redirect(url_for('document.view')) @@ -237,6 +239,9 @@ product = cvrf.getProductForID(productid) except KeyError: abort(404) + if not cvrf.isProductOrphan(product._productid): + flash('Not deleting the Product, it is used in the Document.', 'danger') + return redirect(url_for('.view_product', productid=product._productid)) product.unlink() ptree._products.remove(product) del product @@ -347,6 +352,10 @@ flash('Group not found', 'danger') abort(404) + if not cvrf.isGroupOrphan(group._groupid): + flash('Not deleting group, it is mentionned in the document.', 'danger') + return redirect(url_for('.view')) + cvrf._producttree._groups.remove(group) return redirect(url_for('.view'))