From b54b2d837c0519eb08f4e44458669965d5625de6 Mon Sep 17 00:00:00 2001 From: Mikalai Radchuk Date: Thu, 16 Jun 2016 15:07:07 +0200 Subject: [PATCH] Commands compatibility with Django 1.10 --- .../wagtailcore/management/commands/move_pages.py | 15 +++++++-------- .../management/commands/replace_text.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/wagtail/wagtailcore/management/commands/move_pages.py b/wagtail/wagtailcore/management/commands/move_pages.py index 7ff63902dc..05bd9ed158 100644 --- a/wagtail/wagtailcore/management/commands/move_pages.py +++ b/wagtail/wagtailcore/management/commands/move_pages.py @@ -6,16 +6,15 @@ from wagtail.wagtailcore.models import Page class Command(BaseCommand): - args = " " - - def handle(self, _from_id, _to_id, **options): - # Convert args to integers - from_id = int(_from_id) - to_id = int(_to_id) + def add_arguments(self, parser): + # Positional arguments + parser.add_argument('from_id', type=int) + parser.add_argument('to_id', type=int) + def handle(self, *args, **options): # Get pages - from_page = Page.objects.get(pk=from_id) - to_page = Page.objects.get(pk=to_id) + from_page = Page.objects.get(pk=options['from_id']) + to_page = Page.objects.get(pk=options['to_id']) pages = from_page.get_children() # Move the pages diff --git a/wagtail/wagtailcore/management/commands/replace_text.py b/wagtail/wagtailcore/management/commands/replace_text.py index 3cc0319789..7d7ac53d1d 100644 --- a/wagtail/wagtailcore/management/commands/replace_text.py +++ b/wagtail/wagtailcore/management/commands/replace_text.py @@ -25,9 +25,15 @@ def replace_in_model(model, from_text, to_text): class Command(BaseCommand): - args = " " + def add_arguments(self, parser): + # Positional arguments + parser.add_argument('from_text') + parser.add_argument('to_text') + + def handle(self, *args, **options): + from_text = options['from_text'] + to_text = options['to_text'] - def handle(self, from_text, to_text, **options): for revision in PageRevision.objects.filter(content_json__contains=from_text): revision.content_json = revision.content_json.replace(from_text, to_text) revision.save(update_fields=['content_json'])