From 050f2478d3692467c8ec152645e651d7d8ac99fa Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Fri, 6 Sep 2019 13:01:27 -0500 Subject: [PATCH] Fixes: #3318 - Increases length of platform name and slug to 64 characters (#3353) --- netbox/dcim/forms.py | 4 +++- ...ncrease_field_length_platform_name_slug.py | 23 +++++++++++++++++++ netbox/dcim/models.py | 5 ++-- netbox/project-static/js/forms.js | 3 ++- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 netbox/dcim/migrations/0074_increase_field_length_platform_name_slug.py diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 2a37de4fc..774b69741 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -1242,7 +1242,9 @@ class DeviceRoleCSVForm(forms.ModelForm): # class PlatformForm(BootstrapMixin, forms.ModelForm): - slug = SlugField() + slug = SlugField( + max_length=64 + ) class Meta: model = Platform diff --git a/netbox/dcim/migrations/0074_increase_field_length_platform_name_slug.py b/netbox/dcim/migrations/0074_increase_field_length_platform_name_slug.py new file mode 100644 index 000000000..4fd8f203c --- /dev/null +++ b/netbox/dcim/migrations/0074_increase_field_length_platform_name_slug.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2 on 2019-07-17 20:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dcim', '0073_interface_form_factor_to_type'), + ] + + operations = [ + migrations.AlterField( + model_name='platform', + name='name', + field=models.CharField(max_length=64, unique=True), + ), + migrations.AlterField( + model_name='platform', + name='slug', + field=models.SlugField(max_length=64, unique=True), + ), + ] diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 0a73abd39..29384abcd 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -1385,11 +1385,12 @@ class Platform(ChangeLoggedModel): specifying a NAPALM driver. """ name = models.CharField( - max_length=50, + max_length=64, unique=True ) slug = models.SlugField( - unique=True + unique=True, + max_length=64 ) manufacturer = models.ForeignKey( to='dcim.Manufacturer', diff --git a/netbox/project-static/js/forms.js b/netbox/project-static/js/forms.js index 2469c0f8d..c82529f27 100644 --- a/netbox/project-static/js/forms.js +++ b/netbox/project-static/js/forms.js @@ -47,9 +47,10 @@ $(document).ready(function() { }); if (slug_field) { var slug_source = $('#id_' + slug_field.attr('slug-source')); + var slug_length = slug_field.attr('maxlength'); slug_source.on('keyup change', function() { if (slug_field && !slug_field.attr('_changed')) { - slug_field.val(slugify($(this).val(), 50)); + slug_field.val(slugify($(this).val(), (slug_length ? slug_length : 50))); } }) }