Merge pull request #419 from nephila/hotfix/slug_length

Fix slug fields length due to mysql utf8mb4 encoding
This commit is contained in:
Iacopo Spalletti 2018-01-19 08:02:17 +01:00 committed by GitHub
commit 6cfe1cf13b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -21,12 +21,12 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='blogcategorytranslation', model_name='blogcategorytranslation',
name='name', name='name',
field=models.CharField(max_length=2000, verbose_name='name'), field=models.CharField(max_length=767, verbose_name='name'),
), ),
migrations.AlterField( migrations.AlterField(
model_name='blogcategorytranslation', model_name='blogcategorytranslation',
name='slug', name='slug',
field=models.SlugField(blank=True, max_length=2000, verbose_name='slug'), field=models.SlugField(blank=True, max_length=767, verbose_name='slug'),
), ),
migrations.AlterField( migrations.AlterField(
model_name='posttranslation', model_name='posttranslation',
@ -36,11 +36,11 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='posttranslation', model_name='posttranslation',
name='slug', name='slug',
field=djangocms_blog.fields.AutoSlugField(allow_unicode=True, blank=True, db_index=False, max_length=2000, verbose_name='slug'), field=djangocms_blog.fields.AutoSlugField(allow_unicode=True, blank=True, db_index=False, max_length=767, verbose_name='slug'),
), ),
migrations.AlterField( migrations.AlterField(
model_name='posttranslation', model_name='posttranslation',
name='title', name='title',
field=models.CharField(max_length=2000, verbose_name='title'), field=models.CharField(max_length=767, verbose_name='title'),
), ),
] ]

View file

@ -92,8 +92,8 @@ class BlogCategory(BlogMetaMixin, TranslatableModel):
) )
translations = TranslatedFields( translations = TranslatedFields(
name=models.CharField(_('name'), max_length=2000), name=models.CharField(_('name'), max_length=767),
slug=models.SlugField(_('slug'), max_length=2000, blank=True, db_index=True), slug=models.SlugField(_('slug'), max_length=767, blank=True, db_index=True),
meta_description=models.TextField( meta_description=models.TextField(
verbose_name=_('category meta description'), blank=True, default='' verbose_name=_('category meta description'), blank=True, default=''
), ),
@ -227,8 +227,8 @@ class Post(KnockerModel, BlogMetaMixin, TranslatableModel):
) )
translations = TranslatedFields( translations = TranslatedFields(
title=models.CharField(_('title'), max_length=2000), title=models.CharField(_('title'), max_length=767),
slug=AutoSlugField(_('slug'), max_length=2000, blank=True, slug=AutoSlugField(_('slug'), max_length=767, blank=True,
db_index=True, allow_unicode=True), db_index=True, allow_unicode=True),
abstract=HTMLField(_('abstract'), blank=True, default=''), abstract=HTMLField(_('abstract'), blank=True, default=''),
meta_description=models.TextField(verbose_name=_('post meta description'), meta_description=models.TextField(verbose_name=_('post meta description'),

View file

@ -82,12 +82,12 @@ class AdminTest(BaseTest):
# Add view only contains the apphook selection widget # Add view only contains the apphook selection widget
response = post_admin.add_view(request) response = post_admin.add_view(request)
self.assertNotContains(response, '<input id="id_slug" maxlength="2000" name="slug" type="text"') self.assertNotContains(response, '<input id="id_slug" maxlength="767" name="slug" type="text"')
self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk) self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk)
# Changeview is 'normal' # Changeview is 'normal'
response = post_admin.change_view(request, str(post.pk)) response = post_admin.change_view(request, str(post.pk))
self.assertContains(response, '<input id="id_slug" maxlength="2000" name="slug" type="text" value="first-post" />') self.assertContains(response, '<input id="id_slug" maxlength="767" name="slug" type="text" value="first-post" />')
self.assertContains(response, 'id="id_meta_description" maxlength="320"') self.assertContains(response, 'id="id_meta_description" maxlength="320"')
self.assertContains(response, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk) self.assertContains(response, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk)
@ -184,12 +184,12 @@ class AdminTest(BaseTest):
# Add view only has an empty form - no type # Add view only has an empty form - no type
response = category_admin.add_view(request) response = category_admin.add_view(request)
self.assertNotContains(response, 'id="id_name" maxlength="2000" name="name" type="text" value="category 1"') self.assertNotContains(response, 'id="id_name" maxlength="767" name="name" type="text" value="category 1"')
self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk) self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk)
# Changeview is 'normal', with a few preselected items # Changeview is 'normal', with a few preselected items
response = category_admin.change_view(request, str(self.category_1.pk)) response = category_admin.change_view(request, str(self.category_1.pk))
self.assertContains(response, 'id="id_name" maxlength="2000" name="name" type="text" value="category 1"') self.assertContains(response, 'id="id_name" maxlength="767" name="name" type="text" value="category 1"')
self.assertContains(response, 'id="id_meta_description" maxlength="320"') self.assertContains(response, 'id="id_meta_description" maxlength="320"')
self.assertContains(response, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk) self.assertContains(response, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk)