Mercurial > farol > farol
diff farol/producttree.py @ 80:c00f20bd90ba
Allow deletion of (orphaned) Branches
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Thu, 09 Oct 2014 12:16:55 +0200 |
parents | 264d4579f6bf |
children | d6fa288e92a7 |
line wrap: on
line diff
--- a/farol/producttree.py Thu Oct 09 12:16:16 2014 +0200 +++ b/farol/producttree.py Thu Oct 09 12:16:55 2014 +0200 @@ -107,6 +107,25 @@ ptree.addBranch(branch) return redirect(url_for('.view')) +@producttree.route('/branch/<path:path>/del', methods=['POST']) +@document_required +@producttree_required +def del_branch(path): + path = [int(p) for p in path.split('/')] + cvrf = get_current() + ptree = cvrf._producttree + try: branch = cvrf._producttree.getBranch(path) + except (ValueError, IndexError): + flash('Cannot find Branch', 'danger') + abort(404) + if branch._childs: + flash('Cannot delete a branch with childs', 'danger') + abort(403) + branch.unlink() + del branch + return redirect(url_for('.view')) + + @producttree.route('/product/<productid>') @document_required @producttree_required