"""Update Todo and its children."""
# pylint: disable=too-many-locals
# pylint: disable=too-many-branches
- adopted_child_ids = self._form.get_all_int('adopt')
+ adoptees = self._form.get_all_int('adopt')
to_make = {'full': self._form.get_all_int('make_full'),
'empty': self._form.get_all_int('make_empty')}
step_fillers = self._form.get_all_str('step_filler')
elif filler.startswith('make_full_'):
to_make['full'] += [target_id]
else:
- adopted_child_ids += [target_id]
+ adoptees += [target_id]
#
todo.set_condition_relations(self._conn, *cond_rels)
- to_remove = []
- for child in todo.children:
- if child.id_ and (child.id_ not in adopted_child_ids):
- to_remove += [child.id_]
- for id_ in to_remove:
- child = Todo.by_id(self._conn, id_)
- todo.remove_child(child)
- for child_id in adopted_child_ids:
- if child_id not in [c.id_ for c in todo.children]:
- todo.add_child(Todo.by_id(self._conn, child_id))
+ for child in [c for c in todo.children if c.id_ not in adoptees]:
+ todo.remove_child(child)
+ for child_id in [id_ for id_ in adoptees
+ if id_ not in [c.id_ for c in todo.children]]:
+ todo.add_child(Todo.by_id(self._conn, child_id))
todo.update_attrs(**to_update)
for approach, proc_ids in to_make.items():
for process_id in proc_ids:
# set relations to Conditions and ProcessSteps / other Processes
process.set_condition_relations(self._conn, *cond_rels)
owned_steps = []
- for step_id in kept_steps: # collecting sub-steps
+ for step_id in kept_steps:
owned_steps += [ProcessStep.by_id(self._conn, step_id)]
owned_steps += [ # new sub-steps
ProcessStep(None, process.id_, step_process_id, step_id)