diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d7920fd2fd..e3ccf7247e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -14,6 +14,7 @@ Changelog * Fix: Parent page link in page search modal no longer disappears on hover (Dan Braghis) * Fix: ModelAdmin views now consistently call `get_context_data` (Andy Babic) * Fix: Header for search results on the redirects index page now shows the correct count when the listing is paginated (Nick Smith) + * Fix: `set_url_paths` management command is now compatible with Django 1.10 (Benjamin Bach) 1.7 (20.10.2016) diff --git a/docs/releases/1.8.rst b/docs/releases/1.8.rst index c40de51d21..9354c3cc1f 100644 --- a/docs/releases/1.8.rst +++ b/docs/releases/1.8.rst @@ -29,6 +29,7 @@ Bug fixes * Parent page link in page search modal no longer disappears on hover (Dan Braghis) * ModelAdmin views now consistently call ``get_context_data`` (Andy Babic) * Header for search results on the redirects index page now shows the correct count when the listing is paginated (Nick Smith) + * ``set_url_paths`` management command is now compatible with Django 1.10 (Benjamin Bach) Upgrade considerations ====================== diff --git a/wagtail/wagtailcore/management/commands/set_url_paths.py b/wagtail/wagtailcore/management/commands/set_url_paths.py index 5e26ec87ac..a30b3930e8 100644 --- a/wagtail/wagtailcore/management/commands/set_url_paths.py +++ b/wagtail/wagtailcore/management/commands/set_url_paths.py @@ -1,17 +1,20 @@ from __future__ import absolute_import, unicode_literals -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand from wagtail.wagtailcore.models import Page -class Command(NoArgsCommand): +class Command(BaseCommand): + + help = 'Resets url_path fields on each page recursively' + def set_subtree(self, root, root_path): root.url_path = root_path root.save(update_fields=['url_path']) for child in root.get_children(): self.set_subtree(child, root_path + child.slug + '/') - def handle_noargs(self, **options): + def handle(self, *args, **options): for node in Page.get_root_nodes(): self.set_subtree(node, '/') diff --git a/wagtail/wagtailcore/tests/test_management_commands.py b/wagtail/wagtailcore/tests/test_management_commands.py index 1d7b0528f0..ebf8412d19 100644 --- a/wagtail/wagtailcore/tests/test_management_commands.py +++ b/wagtail/wagtailcore/tests/test_management_commands.py @@ -132,6 +132,17 @@ class TestMovePagesCommand(TestCase): self.assertEqual(Page.objects.get(id=page_id).get_parent(), about_us) +class TestSetUrlPathsCommand(TestCase): + + fixtures = ['test.json'] + + def run_command(self): + management.call_command('set_url_paths', interactive=False, stdout=StringIO()) + + def test_set_url_paths(self): + self.run_command() + + class TestReplaceTextCommand(TestCase): fixtures = ['test.json']