0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Merge branch 'kaedroho-redirects-fixes'

This commit is contained in:
Matt Westcott 2015-09-03 16:30:26 +01:00
commit e2ecac51b9
5 changed files with 9 additions and 3 deletions

View File

@ -42,6 +42,7 @@ Changelog
* Fix: Page copy now works with pages that use multiple inheritance (Jordi Joan)
* Fix: Form builder pages now pick up template variables defined in the `get_context` method (Christoph Lipp)
* Fix: When copying a page, IDs of child objects within page revision records were not remapped to the new objects; this would cause those objects to be lost from the original page when editing the new one
* Fix: Newly added redirects now take effect on all sites, rather than just the site that the Wagtail admin backend was accessed through
1.0 (16.07.2015)

View File

@ -83,6 +83,7 @@ Bug fixes
* Page copy now works with pages that use multiple inheritance
* Form builder pages now pick up template variables defined in the ``get_context`` method
* When copying a page, IDs of child objects within page revision records were not remapped to the new objects; this would cause those objects to be lost from the original page when editing the new one
* Newly added redirects now take effect on all sites, rather than just the site that the Wagtail admin backend was accessed through
Upgrade considerations

View File

@ -40,6 +40,9 @@ class Redirect(models.Model):
@staticmethod
def normalise_path(url):
# Strip whitespace
url = url.strip()
# Parse url
url_parsed = urlparse(url)

View File

@ -20,6 +20,8 @@ class TestRedirects(TestCase):
self.assertEqual(path, normalise_path('Hello/world.html/?foo=Bar&Baz=quux2')) # Trailing slashes are ignored
self.assertEqual(path, normalise_path('/Hello/world.html?foo=Bar&Baz=quux2#cool')) # Fragments are ignored
self.assertEqual(path, normalise_path('/Hello/world.html?Baz=quux2&foo=Bar')) # Order of query string parameters are ignored
self.assertEqual(path, normalise_path(' /Hello/world.html?foo=Bar&Baz=quux2')) # Leading whitespace
self.assertEqual(path, normalise_path('/Hello/world.html?foo=Bar&Baz=quux2 ')) # Trailing whitespace
# Test against different paths
self.assertNotEqual(path, normalise_path('/hello/world.html?foo=Bar&Baz=quux2')) # 'hello' is lowercase
@ -119,6 +121,7 @@ class TestRedirectsAddView(TestCase, WagtailTestUtils):
redirects = models.Redirect.objects.filter(old_path='/test')
self.assertEqual(redirects.count(), 1)
self.assertEqual(redirects.first().redirect_link, 'http://www.test.com/')
self.assertEqual(redirects.first().site, None)
def test_add_validation_error(self):
response = self.post({

View File

@ -108,9 +108,7 @@ def add(request):
if request.POST:
form = form_class(request.POST, request.FILES)
if form.is_valid():
theredirect = form.save(commit=False)
theredirect.site = request.site
theredirect.save()
theredirect = form.save()
messages.success(request, _("Redirect '{0}' added.").format(theredirect.title), buttons=[
messages.button(reverse('wagtailredirects:edit', args=(theredirect.id,)), _('Edit'))