changeset 82:d6fa288e92a7

Update to latest farolluz (unlink/link)
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 14:26:15 +0200
parents 65c874b2c78e
children 2ecf13200e87
files farol/producttree.py
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/farol/producttree.py	Thu Oct 09 12:28:36 2014 +0200
+++ b/farol/producttree.py	Thu Oct 09 14:26:15 2014 +0200
@@ -81,9 +81,7 @@
         # 1. unlink
         branch.unlink()
         # 2. set the new parent
-        branch._parentbranch = pbranch
-        # 3. add to the Tree (again)
-        ptree.addBranch(branch)
+        branch.link(pbranch)
 
     branch._type = request.form['type']
     branch._name = request.form['name']
@@ -104,7 +102,6 @@
         try: pbranch = ptree.getBranch([int(p) for p in request.form['parent'].split('/')])
         except (ValueError, IndexError): abort(404)
     branch = CVRFProductBranch(request.form['type'], request.form['name'], pbranch)
-    ptree.addBranch(branch)
     return redirect(url_for('.view'))
 
 @producttree.route('/branch/<path:path>/del', methods=['POST'])
@@ -167,19 +164,21 @@
         if pbranch is not oldp:
             # Gonna be funny, needs re-link
             product.unlink()
-            product._parent = pbranch
-            ptree.addProduct(product)
+            # And Link again
+            product.link(pbranch)
     elif request.form['parent_relationship']:
         prel = ptree._relationships[int(request.form['parent_relationship'])]
         if prel is not oldp:
+            # Unlink
             product.unlink()
-            product._parent = prel
-            ptree.addProduct(product)
+            # Link again
+            product.link(prel)
     else:
         if ptree is not oldp:
+            # Unlink
             product.unlink()
-            product._parent = ptree
-            ptree.addProduct(product)
+            # Link again
+            product.link(ptree)
 
     product._productid = request.form['productid']
     product._name = request.form['name']

http://farol.wald.intevation.org