Skip to content

Commit

Permalink
Improved performance of 'cms list plugins'. (#6718)
Browse files Browse the repository at this point in the history
Co-authored-by: Vinit Kumar <mail@vinitkumar.me>
  • Loading branch information
vytisb and vinitkumar committed May 13, 2021
1 parent 4142fc3 commit 1dc0478
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -10,6 +10,7 @@ Unreleased
* Remove debug print from apphook_reload
* Enforce use of coverage > 4 for python 3.8 support
* Fixed 66622 bad Title.path in multilingual sites when parent slug is created or modified
* Improved performance of ``cms list plugins`` command
* Temporarily pinned django-treebeard to < 4.5, this avoids breaking changes introduced
* Fix styles issues, caused by switching to the ``display: flex`` on the page tree renderer.
* Added django-treebeard 4.5.1 support, previously pinned django-treebeard<4.5 to avoid breaking changes introduced
Expand Down
5 changes: 3 additions & 2 deletions cms/management/commands/subcommands/list.py
Expand Up @@ -83,9 +83,10 @@ class ListPluginsCommand(SubcommandsCommand):
command_name = 'plugins'

def handle(self, *args, **options):
report = plugin_report()
self.stdout.write('==== Plugin report ==== \n\n')
self.stdout.write('There are %s plugin types in your database \n' % len(plugin_report()))
for plugin in plugin_report():
self.stdout.write('There are %s plugin types in your database \n' % len(report))
for plugin in report:
self.stdout.write('\n%s \n' % plugin['type'])

plugin_model = plugin['model']
Expand Down
6 changes: 5 additions & 1 deletion cms/tests/test_management.py
@@ -1,5 +1,6 @@
import io
import uuid
import mock

from cms.test_utils.project.sampleapp.cms_apps import SampleApp
from cms.test_utils.util.context_managers import apphooks
Expand Down Expand Up @@ -149,7 +150,10 @@ def test_list_plugins(self):
bogus_plugin = CMSPlugin(language="en", plugin_type="BogusPlugin")
bogus_plugin.save()

management.call_command('cms', 'list', 'plugins', interactive=False, stdout=out)
with mock.patch('cms.management.commands.subcommands.list.plugin_report') as report_fn:
management.call_command('cms', 'list', 'plugins', interactive=False, stdout=out)
report_fn.assert_called_once()

report = plugin_report()

# there should be reports for three plugin types
Expand Down

0 comments on commit 1dc0478

Please sign in to comment.