mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-26 07:43:44 +00:00
Tweaked fixtree command to make it more testable
We can now pass thorough a "delete_orphans" option from the test which simulates a user pressing "y" at the prompt
This commit is contained in:
parent
80b3665dfd
commit
87703c95fd
1 changed files with 12 additions and 8 deletions
|
|
@ -68,15 +68,19 @@ class Command(BaseCommand):
|
|||
|
||||
if options.get('interactive', True):
|
||||
yes_or_no = six.moves.input("Delete these pages? [y/N] ")
|
||||
if yes_or_no.lower().startswith('y'):
|
||||
deletion_count = len(pages_to_delete)
|
||||
pages_to_delete.delete()
|
||||
self.stdout.write(
|
||||
"%d orphaned page%s deleted." % (deletion_count, "s"[deletion_count==1:])
|
||||
)
|
||||
any_problems_fixed = True
|
||||
|
||||
delete_orphans = yes_or_no.lower().startswith('y')
|
||||
self.stdout.write('')
|
||||
else:
|
||||
# Running tests, check for the "delete_orphans" option
|
||||
delete_orphans = options.get('delete_orphans', False)
|
||||
|
||||
if delete_orphans:
|
||||
deletion_count = len(pages_to_delete)
|
||||
pages_to_delete.delete()
|
||||
self.stdout.write(
|
||||
"%d orphaned page%s deleted." % (deletion_count, "s"[deletion_count==1:])
|
||||
)
|
||||
any_problems_fixed = True
|
||||
|
||||
if any_problems_fixed:
|
||||
# re-run find_problems to see if any new ones have surfaced
|
||||
|
|
|
|||
Loading…
Reference in a new issue