Transforming tags to lowercase on creation

remotes/origin/issue/4795/notification_even_they_are_disabled
Alejandro Alonso 2016-11-25 10:00:30 +01:00
parent 86897d3469
commit 26e45907d7
2 changed files with 3 additions and 3 deletions

View File

@ -24,12 +24,12 @@ def tag_exist_for_project_elements(project, tag):
def create_tags(project, new_tags_colors): def create_tags(project, new_tags_colors):
project.tags_colors += [[k, v] for k, v in new_tags_colors.items()] project.tags_colors += [[k.lower(), v] for k, v in new_tags_colors.items()]
project.save(update_fields=["tags_colors"]) project.save(update_fields=["tags_colors"])
def create_tag(project, tag, color): def create_tag(project, tag, color):
project.tags_colors.append([tag, color]) project.tags_colors.append([tag.lower(), color])
project.save(update_fields=["tags_colors"]) project.save(update_fields=["tags_colors"])

View File

@ -50,7 +50,7 @@ class CreateTagValidator(ProjectTagValidator):
def validate_color(self, attrs, source): def validate_color(self, attrs, source):
color = attrs.get(source, None) color = attrs.get(source, None)
if color is not None and not re.match('^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$', color): if color and not re.match('^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$', color):
raise ValidationError(_("The color is not a valid HEX color.")) raise ValidationError(_("The color is not a valid HEX color."))
return attrs return attrs