mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Commands compatibility with Django 1.10
This commit is contained in:
parent
a6f6661e26
commit
b54b2d837c
@ -6,16 +6,15 @@ from wagtail.wagtailcore.models import Page
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = "<from id> <to id>"
|
||||
|
||||
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
|
||||
|
@ -25,9 +25,15 @@ def replace_in_model(model, from_text, to_text):
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = "<from text> <to text>"
|
||||
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'])
|
||||
|
Loading…
Reference in New Issue
Block a user