Code

Fix linking of an existing item to a newly created item, e.g. edit
[roundup.git] / roundup / cgi / actions.py
index eaf4c28a5b57080a455702ecefc997e1d94b3fad..c19849413aff73dc169ead6b0e6ba347f8996267 100755 (executable)
@@ -320,6 +320,11 @@ class EditCSVAction(Action):
                     raise exceptions.Unauthorised, self._(
                         'You do not have permission to create %(class)s'
                     ) % {'class': self.classname}
+            elif cl.hasnode(itemid) and cl.is_retired(itemid):
+                # If a CSV line just mentions an id and the corresponding
+                # item is retired, then the item is restored.
+                cl.restore(itemid)
+                continue
             else:
                 exists = 1
 
@@ -473,9 +478,9 @@ class EditCommon(Action):
                         if linkid is None or linkid.startswith('-'):
                             # linking to a new item
                             if isinstance(propdef, hyperdb.Multilink):
-                                props[linkprop] = [newid]
+                                props[linkprop] = [nodeid]
                             else:
-                                props[linkprop] = newid
+                                props[linkprop] = nodeid
                         else:
                             # linking to an existing item
                             if isinstance(propdef, hyperdb.Multilink):
@@ -483,7 +488,7 @@ class EditCommon(Action):
                                 existing.append(nodeid)
                                 props[linkprop] = existing
                             else:
-                                props[linkprop] = newid
+                                props[linkprop] = nodeid
 
         return '<br>'.join(m)