fix mptt command #1521

Merged
merged 2 commits into from Nov 27, 2012

Projects

None yet

3 participants

@digi604
Member
digi604 commented Nov 19, 2012

Adds a command for fixing the mptt tree

@piquadrat piquadrat commented on an outdated diff Nov 19, 2012
cms/management/commands/subcommands/mptt.py
@@ -0,0 +1,16 @@
+from cms.models import Page, CMSPlugin
+from django.core.management.base import NoArgsCommand
+
+
+class FixMPTTCommand(NoArgsCommand):
+ help = 'Repair MPTT tree for pages'
+
+ def handle_noargs(self, **options):
+ """
+ Repairs the MPTT tree
+ """
+ print "fixing mptt page tree"
@piquadrat
piquadrat Nov 19, 2012 Contributor

self.stdout.write is probably safer than print

@piquadrat
Contributor

I suggest to print a huge warning to please back up the database before running this command and ask for confirmation again (perhaps with a --noprint flag for automated calls)

@BertrandBordage
Contributor

Oh, I didn't saw TreeManager was accessible from Page._tree_manager. Is #1492 therefore invalid?

@digi604 digi604 merged commit 0607ff7 into divio:develop Nov 27, 2012

1 check was pending

default The Travis build is in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment