Add max_length option to redirect URL field

pull/4587/merge
Michael Harrison 2018-06-06 13:24:10 -05:00 zatwierdzone przez Matt Westcott
rodzic 368e3b3adb
commit e2b1c66a92
5 zmienionych plików z 38 dodań i 1 usunięć

Wyświetl plik

@ -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))

Wyświetl plik

@ -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
~~~~~~~~~

Wyświetl plik

@ -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'),
),
]

Wyświetl plik

@ -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):

Wyświetl plik

@ -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):