profile: limit field identifier length (#43036)
This commit is contained in:
parent
29914b6d36
commit
f5ca32f8e0
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.17 on 2020-05-18 18:10
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('profile', '0003_attributedefinition_searchable'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='attributedefinition',
|
||||
name='kind',
|
||||
field=models.CharField(choices=[('string', 'String'), ('boolean', 'Boolean'), ('date', 'Date'), ('title', 'Civility'), ('birthdate', 'Birthdate'), ('fr_postcode', 'French Postcode'), ('phone_number', 'Phone Number'), ('profile_image', 'Profile Image')], default='string', max_length=16, verbose_name='kind'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='attributedefinition',
|
||||
name='name',
|
||||
field=models.SlugField(error_messages={'unique': 'Field names must be unique.'}, unique=True, validators=[django.core.validators.RegexValidator('^[a-z][a-z0-9_]*\\Z', 'Enter valid variable name starting with a letter and consisting of letters, numbers, or underscores.')], verbose_name='name'),
|
||||
),
|
||||
]
|
|
@ -32,7 +32,7 @@ class AttributeDefinition(models.Model):
|
|||
description = models.TextField(verbose_name=_('description'),
|
||||
blank=True)
|
||||
name = models.SlugField(verbose_name=_('name'),
|
||||
max_length=256, unique=True,
|
||||
max_length=50, unique=True,
|
||||
validators=[validate_attribute_name],
|
||||
error_messages={'unique': _('Field names must be unique.')})
|
||||
required = models.BooleanField(verbose_name=_('required'),
|
||||
|
|
|
@ -37,6 +37,6 @@ $(function() {
|
|||
$id_name.data('_changed', false);
|
||||
}
|
||||
if ($id_name.data('_changed')) return;
|
||||
$id_name.val(URLify($(this).val()).replace(/-/g, '_'));
|
||||
$id_name.val(URLify($(this).val()).replace(/-/g, '_').substring(0, 50));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue