Fix Project time is not updated when moved or merged

This commit is contained in:
allegroai 2022-12-21 18:46:53 +02:00
parent a392bc0bd7
commit ed6c7b7bcb

View File

@ -156,11 +156,15 @@ def _update_subproject_names(
Optionally update the paths Optionally update the paths
""" """
updated = 0 updated = 0
now = datetime.utcnow()
for child in children: for child in children:
child_suffix = name_separator.join( child_suffix = name_separator.join(
child.name.split(name_separator)[len(old_name.split(name_separator)) :] child.name.split(name_separator)[len(old_name.split(name_separator)) :]
) )
updates = {"name": name_separator.join((project.name, child_suffix))} updates = {
"name": name_separator.join((project.name, child_suffix)),
"last_update": now,
}
if update_path: if update_path:
updates["path"] = project.path + child.path[len(old_path) :] updates["path"] = project.path + child.path[len(old_path) :]
updated += child.update(upsert=False, **updates) updated += child.update(upsert=False, **updates)
@ -177,6 +181,7 @@ def _reposition_project_with_children(
project.name = name_separator.join( project.name = name_separator.join(
filter(None, (new_location, project.name.split(name_separator)[-1])) filter(None, (new_location, project.name.split(name_separator)[-1]))
) )
project.last_update = datetime.utcnow()
_save_under_parent(project, parent=parent) _save_under_parent(project, parent=parent)
moved = 1 + _update_subproject_names( moved = 1 + _update_subproject_names(