def handle_noargs(self, **options):
        """
        Obtains a plugin report -
        cms.management.commands.subcommands.list.plugin_report - and uses it
        to delete orphaned plugins from the database, i.e. ones that are no
        longer installed, and ones that have no corresponding saved plugin
        instances (as will happen if a plugin is inserted into a placeholder,
        but not saved).
        """
        self.stdout.write(u"Obtaining plugin report\n")
        uninstalled_instances = []
        unsaved_instances = []

        for plugin in plugin_report():
            if not plugin["model"]:
                for instance in plugin["instances"]:
                    uninstalled_instances.append(instance)

            for instance in plugin["unsaved_instances"]:
                unsaved_instances.append(instance)

        if options.get('interactive'):
            confirm = raw_input(
                """
You have requested to delete any instances of uninstalled plugins and unsaved plugin instances.
There are %d uninstalled plugins and %d unsaved_plugins.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: """ %
                (len(uninstalled_instances), len(unsaved_instances)))
        else:
            confirm = 'yes'

        if confirm == 'yes':
            # delete items whose plugin is uninstalled and items with unsaved instances
            self.stdout.write(
                u"... deleting any instances of uninstalled plugins and unsaved plugin instances\n"
            )

            for instance in uninstalled_instances:
                instance.delete()

            for instance in unsaved_instances:
                instance.delete()

            self.stdout.write(
                u"Deleted instances of: \n    %s uninstalled plugins  \n    %s plugins with unsaved instances\n"
                % (len(uninstalled_instances), len(unsaved_instances)))
            self.stdout.write(u"all done\n")
Exemplo n.º 2
0
    def handle_label(self, label, **options):
        queryset = CMSPlugin.objects.filter(plugin_type=label)
        number_of_plugins = queryset.count()

        if number_of_plugins > 0:
            if options.get('interactive'):
                confirm = raw_input("""
You have requested to remove %d %r plugins.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: """ % (number_of_plugins, label))
            else:
                confirm = 'yes'
            queryset.delete()
            self.stdout.write(u'%d %r plugins uninstalled\n' % (number_of_plugins, label))
        else:
            self.stdout.write(u'no %r plugins found\n' % label)
    def handle_label(self, label, **options):
        queryset = CMSPlugin.objects.filter(plugin_type=label)
        number_of_plugins = queryset.count()

        if number_of_plugins > 0:
            if options.get('interactive'):
                confirm = raw_input("""
You have requested to remove %d %r plugins.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: """ % (number_of_plugins, label))
            else:
                confirm = 'yes'
            queryset.delete()
            self.stdout.write(u'%d %r plugins uninstalled\n' %
                              (number_of_plugins, label))
        else:
            self.stdout.write(u'no %r plugins found\n' % label)
Exemplo n.º 4
0
    def handle_label(self, label, **options):
        queryset = Page.objects.filter(application_urls=label)
        number_of_apphooks = queryset.count()

        if number_of_apphooks > 0:
            if options.get('interactive'):
                confirm = raw_input("""
You have requested to remove %d %r apphooks.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: """ % (number_of_apphooks, label))
            else:
                confirm = 'yes'
            if confirm == 'yes':
                queryset.update(application_urls=None)
                self.stdout.write(u'%d %r apphooks uninstalled\n' % (number_of_apphooks, label))
        else:
            self.stdout.write(u'no %r apphooks found\n' % label)
Exemplo n.º 5
0
    def handle_label(self, label, **options):
        queryset = Page.objects.filter(application_urls=label)
        number_of_apphooks = queryset.count()

        if number_of_apphooks > 0:
            if options.get('interactive'):
                confirm = raw_input("""
You have requested to remove %d %r apphooks.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: """ % (number_of_apphooks, label))
            else:
                confirm = 'yes'
            if confirm == 'yes':
                queryset.update(application_urls=None)
                self.stdout.write(u'%d %r apphooks uninstalled\n' %
                                  (number_of_apphooks, label))
        else:
            self.stdout.write(u'no %r apphooks found\n' % label)
    def handle_noargs(self, **options):
        """
        Obtains a plugin report -
        cms.management.commands.subcommands.list.plugin_report - and uses it
        to delete orphaned plugins from the database, i.e. ones that are no
        longer installed, and ones that have no corresponding saved plugin
        instances (as will happen if a plugin is inserted into a placeholder,
        but not saved).
        """
        self.stdout.write(u"Obtaining plugin report\n")
        uninstalled_instances = []
        unsaved_instances = []

        for plugin in plugin_report():
            if not plugin["model"]:
                for instance in plugin["instances"]:
                    uninstalled_instances.append(instance)

            for instance in plugin["unsaved_instances"]:
                unsaved_instances.append(instance)

        if options.get('interactive'):
            confirm = raw_input("""
You have requested to delete any instances of uninstalled plugins and unsaved plugin instances.
There are %d uninstalled plugins and %d unsaved_plugins.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: """ % (len(uninstalled_instances), len(unsaved_instances)))
        else:
            confirm = 'yes'

        if confirm == 'yes':
            # delete items whose plugin is uninstalled and items with unsaved instances
            self.stdout.write(u"... deleting any instances of uninstalled plugins and unsaved plugin instances\n")

            for instance in uninstalled_instances:
                instance.delete()

            for instance in unsaved_instances:
                instance.delete()

            self.stdout.write(u"Deleted instances of: \n    %s uninstalled plugins  \n    %s plugins with unsaved instances\n" % (len(uninstalled_instances), len(unsaved_instances)))
            self.stdout.write(u"all done\n")