Browse Source

Allow promoting tasks to the top level

tags/0.0.1b
Timur Demin 1 month ago
parent
commit
022922313f
Signed by: Timur Demin <me@tdem.in> GPG Key ID: 9EDF3F9D9286FA20
1 changed files with 12 additions and 7 deletions
  1. 12
    7
      project_amber/helpers/task.py

+ 12
- 7
project_amber/helpers/task.py View File

@@ -65,13 +65,18 @@ def updateTask(task_id: int, uid: int, **kwargs) -> int:
65 65
     if "status" in kwargs and not kwargs["status"] is None:
66 66
         task.status = kwargs["status"]
67 67
     if "parent_id" in kwargs and not kwargs["parent_id"] is None:
68
-        # TODO: we limit changing parent IDs to prevent circular deps,
69
-        # can this be done better?
70
-        new_parent = getTask(kwargs["parent_id"], uid)
71
-        if new_parent.gen > task.gen and task.is_child():
72
-            raise BadRequest(MSG_TASK_DANGEROUS)
73
-        task.parent_id = new_parent.id
74
-        updateChildren(task.id)
68
+        if kwargs["parent_id"] == 0:
69
+            # promote task to the top level
70
+            task.parent_id = None
71
+            updateChildren(task.id)
72
+        else:
73
+            # TODO: we limit changing parent IDs to prevent circular deps,
74
+            # can this be done better?
75
+            new_parent = getTask(kwargs["parent_id"], uid)
76
+            if new_parent.gen > task.gen and task.is_child():
77
+                raise BadRequest(MSG_TASK_DANGEROUS)
78
+            task.parent_id = new_parent.id
79
+            updateChildren(task.id)
75 80
     task.last_mod_time = time()
76 81
     db.session.commit()
77 82
     return task_id

Loading…
Cancel
Save