Skip to content

Commit 40fa8d9

Browse files
authored
fix: Add --fix-paths option to ./manage.py cms fix-tree (#7744)
1 parent fc18e26 commit 40fa8d9

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

cms/management/commands/subcommands/tree.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,24 @@ def get_descendants(root):
2222

2323

2424
class FixTreeCommand(SubcommandsCommand):
25-
help_string = 'Repairing Materialized Path Tree for Pages'
25+
help_string = 'Repairing Materialized Path Tree for Pages and Plugins'
2626
command_name = 'fix-tree'
2727

28+
def add_arguments(self, parser):
29+
parser.add_argument(
30+
'--fix-paths',
31+
action='store_true',
32+
default=False,
33+
help='Fix paths for pages and plugins - takes a long time',
34+
)
35+
2836
def handle(self, *args, **options):
2937
"""
3038
Repairs the tree
3139
"""
40+
fix_paths = options.get('fix_paths', False)
3241
self.stdout.write('fixing page tree')
33-
TreeNode.fix_tree()
42+
TreeNode.fix_tree(fix_paths=fix_paths)
3443

3544
root_nodes = TreeNode.objects.filter(parent__isnull=True)
3645

@@ -54,7 +63,7 @@ def handle(self, *args, **options):
5463
self._update_descendants_tree(root)
5564

5665
self.stdout.write('fixing plugin tree')
57-
CMSPlugin.fix_tree()
66+
CMSPlugin.fix_tree(fix_paths=fix_paths)
5867
self.stdout.write('all done')
5968

6069
def _update_descendants_tree(self, root):

cms/models/pluginmodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,14 @@ def copy_plugin(self, target_placeholder, target_language, parent_cache, no_sign
355355
return new_plugin
356356

357357
@classmethod
358-
def fix_tree(cls, destructive=False):
358+
def fix_tree(cls, **kwargs):
359359
"""
360360
Fixes the plugin tree by first calling treebeard fix_tree and the
361361
recalculating the correct position property for each plugin.
362362
"""
363363
from cms.utils.plugins import reorder_plugins
364364

365-
super().fix_tree(destructive)
365+
super().fix_tree(**kwargs)
366366
for placeholder in Placeholder.objects.all():
367367
for language, __ in settings.LANGUAGES:
368368
order = CMSPlugin.objects.filter(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'Django>=3.2',
1010
'django-classy-tags>=0.7.2',
1111
'django-formtools>=2.1',
12-
'django-treebeard>=4.3',
12+
'django-treebeard>=4.3,!=4.5',
1313
'django-sekizai>=0.7',
1414
'djangocms-admin-style>=1.2',
1515
'packaging',

0 commit comments

Comments
 (0)