From fde98473c4b0f3ed18d18cf6fd0c6833870166fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 9 Jun 2016 19:18:52 +0200 Subject: [PATCH] Keep the to_tag color on mix_tags service function --- taiga/projects/services/tags.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/taiga/projects/services/tags.py b/taiga/projects/services/tags.py index ea009df7..010a23fb 100644 --- a/taiga/projects/services/tags.py +++ b/taiga/projects/services/tags.py @@ -53,8 +53,8 @@ def edit_tag(project, from_tag, to_tag=None, color=None): project.save() -def rename_tag(project, from_tag, to_tag): - color = dict(project.tags_colors)[from_tag] +def rename_tag(project, from_tag, to_tag, color=None): + color = color or dict(project.tags_colors)[from_tag] sql = """ UPDATE userstories_userstory SET tags = array_distinct(array_replace(tags, '{from_tag}', '{to_tag}')) WHERE project_id={project_id}; UPDATE tasks_task SET tags = array_distinct(array_replace(tags, '{from_tag}', '{to_tag}')) WHERE project_id={project_id}; @@ -65,7 +65,8 @@ def rename_tag(project, from_tag, to_tag): cursor.execute(sql) tags_colors = dict(project.tags_colors) - tags_colors[to_tag] = tags_colors.pop(from_tag) + tags_colors.pop(from_tag) + tags_colors[to_tag] = color project.tags_colors = list(tags_colors.items()) project.save() @@ -87,5 +88,6 @@ def delete_tag(project, tag): def mix_tags(project, from_tags, to_tag): + color = dict(project.tags_colors)[to_tag] for from_tag in from_tags: - rename_tag(project, from_tag, to_tag) + rename_tag(project, from_tag, to_tag, color)