home · contact · privacy
Draw Process descendant trees, and guard against recursion within them.
[plomtask] / templates / process.html
index f2ef5aa95e12cd78b901afe73ba3fd88c050d8e5..f2d5055043da9388f488b37cf4336c6423dd1cab 100644 (file)
@@ -1,5 +1,20 @@
 {% extends 'base.html' %}
 
+{% macro process_with_children(node, indent) %}
+<tr>
+<td>
+<input type="checkbox" name="children" value="{{node.process.id_}}" checked />
+</td>
+<td>
+{% for i in range(indent) %}+{%endfor %}
+<a href="process?id={{node.process.id_}}">{{node.process.title.newest|e}}</a>
+</td>
+</tr>
+{% for child in node.children.values() %}
+{{ process_with_children(child, indent+1) }}
+{% endfor %}
+{% endmacro %}
+
 {% block content %}
 <h3>Process</h3>
 <form action="process?id={{process.id_ or ''}}" method="POST">
@@ -7,15 +22,8 @@ title: <input name="title" value="{{process.title.newest|e}}" />
 description: <input name="description" value="{{process.description.newest|e}}" />
 default effort: <input name="effort" type="number" step=0.1 value={{process.effort.newest}} />
 <table>
-{% for child in children %}
-<tr>
-<td>
-<input type="checkbox" name="children" value="{{child.id_}}" checked />
-</td>
-<td>
-<a href="process?id={{child.id_}}">{{child.title.newest|e}}</a>
-</td>
-</tr>
+{% for child in children.values() %}
+{{ process_with_children(child, 0) }}
 {% endfor %}
 </table>
 add child: <input name="children" list="candidates" autocomplete="off" />