diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e48816fa00..dbfdd64193 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -13,6 +13,7 @@ Changelog * Update documentation (configuring Django for Wagtail) to contain all current settings options (Matt Westcott, LB (Ben Johnston)) * Added `defer` flag to `PageQuerySet.specific` (Karl Hobley) * Snippets can now be deleted from the listing view (LB (Ben Johnston)) + * Increased max length of redirect URL field to 255 (Michael Harrison) * Fix: Handle all exceptions from `Image.get_file_size` (Andrew Plummer) * Fix: Fix display of breadcrumbs in ModelAdmin (LB (Ben Johnston)) diff --git a/docs/releases/2.2.rst b/docs/releases/2.2.rst index 2952aa5ef4..803da92d78 100644 --- a/docs/releases/2.2.rst +++ b/docs/releases/2.2.rst @@ -22,6 +22,7 @@ Other features * Update documentation (configuring Django for Wagtail) to contain all current settings options (Matt Westcott, LB (Ben Johnston)) * Added ``defer`` flag to ``PageQuerySet.specific`` (Karl Hobley) * Snippets can now be deleted from the listing view (LB (Ben Johnston)) + * Increased max length of redirect URL field to 255 (Michael Harrison) Bug fixes ~~~~~~~~~ diff --git a/wagtail/contrib/redirects/migrations/0006_redirect_increase_max_length.py b/wagtail/contrib/redirects/migrations/0006_redirect_increase_max_length.py new file mode 100644 index 0000000000..bed3fc554a --- /dev/null +++ b/wagtail/contrib/redirects/migrations/0006_redirect_increase_max_length.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.2 on 2018-06-06 18:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailredirects', '0005_capitalizeverbose'), + ] + + operations = [ + migrations.AlterField( + model_name='redirect', + name='redirect_link', + field=models.URLField(blank=True, max_length=255, verbose_name='redirect to any URL'), + ), + ] diff --git a/wagtail/contrib/redirects/models.py b/wagtail/contrib/redirects/models.py index f389e4ed8d..6897d144d3 100644 --- a/wagtail/contrib/redirects/models.py +++ b/wagtail/contrib/redirects/models.py @@ -24,7 +24,7 @@ class Redirect(models.Model): null=True, blank=True, on_delete=models.CASCADE ) - redirect_link = models.URLField(verbose_name=_("redirect to any URL"), blank=True) + redirect_link = models.URLField(verbose_name=_("redirect to any URL"), blank=True, max_length=255) @property def title(self): diff --git a/wagtail/contrib/redirects/tests.py b/wagtail/contrib/redirects/tests.py index 15b6434907..4e9140a1e8 100644 --- a/wagtail/contrib/redirects/tests.py +++ b/wagtail/contrib/redirects/tests.py @@ -422,6 +422,23 @@ class TestRedirectsAddView(TestCase, WagtailTestUtils): redirects = models.Redirect.objects.filter(redirect_link='http://www.test.com/') self.assertEqual(redirects.count(), 1) + def test_add_long_redirect(self): + response = self.post({ + 'old_path': '/test', + 'site': '', + 'is_permanent': 'on', + 'redirect_link': 'https://www.google.com/search?q=this+is+a+very+long+url+because+it+has+a+huge+search+term+appended+to+the+end+of+it+even+though+someone+should+really+not+be+doing+something+so+crazy+without+first+seeing+a+psychiatrist', + }) + + # Should redirect back to index + self.assertRedirects(response, reverse('wagtailredirects:index')) + + # Check that the redirect was created + redirects = models.Redirect.objects.filter(old_path='/test') + self.assertEqual(redirects.count(), 1) + self.assertEqual(redirects.first().redirect_link, 'https://www.google.com/search?q=this+is+a+very+long+url+because+it+has+a+huge+search+term+appended+to+the+end+of+it+even+though+someone+should+really+not+be+doing+something+so+crazy+without+first+seeing+a+psychiatrist') + self.assertEqual(redirects.first().site, None) + class TestRedirectsEditView(TestCase, WagtailTestUtils): def setUp(self):