cms.management.commands.subcommands.uninstall: 38 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/cms/management/commands/subcommands/uninstall.py

Stats: 0 executed, 34 missed, 4 excluded, 22 ignored

  1. # -*- coding: utf-8 -*-
  2. from cms.management.commands.subcommands.base import SubcommandsCommand
  3. from cms.models.pluginmodel import CMSPlugin
  4. from cms.models.titlemodels import Title
  5. from django.core.management.base import LabelCommand
  6. class UninstallApphooksCommand(LabelCommand):
  7. args = "APPHOK_NAME"
  8. label = 'apphook name (eg SampleApp)'
  9. help = 'Uninstalls (sets to null) specified apphooks for all pages'
  10. def handle_label(self, label, **options):
  11. queryset = Title.objects.filter(application_urls=label)
  12. number_of_apphooks = queryset.count()
  13. if number_of_apphooks > 0:
  14. if options.get('interactive'):
  15. confirm = raw_input("""
  16. You have requested to remove %d %r apphooks.
  17. Are you sure you want to do this?
  18. Type 'yes' to continue, or 'no' to cancel: """ % (number_of_apphooks, label))
  19. else:
  20. confirm = 'yes'
  21. if confirm == 'yes':
  22. queryset.update(application_urls=None)
  23. self.stdout.write('%d %r apphooks uninstalled\n' % (number_of_apphooks, label))
  24. else:
  25. self.stdout.write('no %r apphooks found\n' % label)
  26. class UninstallPluginsCommand(LabelCommand):
  27. args = "PLUGIN_NAME"
  28. label = 'plugin name (eg SamplePlugin)'
  29. help = 'Uninstalls (deletes) specified plugins from the CMSPlugin model'
  30. def handle_label(self, label, **options):
  31. queryset = CMSPlugin.objects.filter(plugin_type=label)
  32. number_of_plugins = queryset.count()
  33. if number_of_plugins > 0:
  34. if options.get('interactive'):
  35. confirm = raw_input("""
  36. You have requested to remove %d %r plugins.
  37. Are you sure you want to do this?
  38. Type 'yes' to continue, or 'no' to cancel: """ % (number_of_plugins, label))
  39. else:
  40. confirm = 'yes'
  41. queryset.delete()
  42. self.stdout.write('%d %r plugins uninstalled\n' % (number_of_plugins, label))
  43. else:
  44. self.stdout.write('no %r plugins found\n' % label)
  45. class UninstallCommand(SubcommandsCommand):
  46. help = 'Uninstall commands'
  47. subcommands = {
  48. 'apphooks': UninstallApphooksCommand,
  49. 'plugins': UninstallPluginsCommand
  50. }