PageRenderTime 20ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/feincms/management/commands/rebuild_mptt.py

http://github.com/feincms/feincms
Python | 29 lines | 13 code | 7 blank | 9 comment | 0 complexity | 03ddc5b1814c10b54660bec2734c9a77 MD5 | raw file
 1# ------------------------------------------------------------------------
 2# coding=utf-8
 3# ------------------------------------------------------------------------
 4"""
 5``rebuild_mptt``
 6---------------------
 7
 8``rebuild_mptt`` rebuilds your mptt pointers. Only use in emergencies.
 9"""
10
11from __future__ import absolute_import, unicode_literals
12
13try:
14    from django.core.management.base import NoArgsCommand as BaseCommand
15except ImportError:
16    from django.core.management.base import BaseCommand
17
18from feincms.module.page.models import Page
19
20
21class Command(BaseCommand):
22    help = "Run this manually to rebuild your mptt pointers. Only use in emergencies."
23
24    def handle_noargs(self, **options):
25        self.handle(**options)
26
27    def handle(self, **options):
28        self.stdout.write("Rebuilding MPTT pointers for Page")
29        Page._tree_manager.rebuild()