Skip to content
Snippets Groups Projects
Commit 90c8b2c8 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Restrict tag name characters

If a tag's name has some "uncommon" characters in it, like
parentheses (or probably others), it will cause errors for the
javascript which renders the event pages, since it tries to use
the tag name in the element id for the delete button.  We now require
that tags only use 0-9a-zA-Z_\- in their names. May have to go through
and delete some tags which use them.
parent 6dea25ee
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-06-07 18:57
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('events', '0021_emobservation_N_not_editable'),
]
operations = [
migrations.AlterField(
model_name='tag',
name='name',
field=models.CharField(max_length=100, unique=True, validators=[django.core.validators.RegexValidator(code=b'invalid_tag_name', message=b'Tag names can only include [0-9a-zA-z_-]', regex=b'^[0-9a-zA-Z_\\-]*$')]),
),
]
......@@ -808,7 +808,14 @@ class Tag(CleanSaveModel):
track those things? Doesn't seem like it.
"""
name = models.CharField(max_length=100, null=False, blank=False,
unique=True)
unique=True,
validators=[
models.fields.validators.RegexValidator(
regex=r'^[0-9a-zA-Z_\-]*$',
message="Tag names can only include [0-9a-zA-z_-]",
code="invalid_tag_name",
)
])
displayName = models.CharField(max_length=200, null=True, blank=True)
def __unicode__(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment