Skip to content

Commit ac62acd

Browse files
committed
Allow plugin registration using a decorator as well.
For example: @plugin_pool.register_plugin class DecoratorTestPlugin(CMSPluginBase): ...
1 parent 07e2b2e commit ac62acd

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cms/plugin_pool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def register_plugin(self, plugin):
106106
except RegistrationError:
107107
pass
108108

109+
return plugin
110+
109111
def unregister_plugin(self, plugin):
110112
"""
111113
Unregisters the given plugin(s).

cms/tests/plugins.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,13 @@ def test_plugin_translatable_content_getter_setter(self):
10921092
# double check through the getter
10931093
self.assertEqual({'body': "It works!"}, plugin.get_translatable_content())
10941094

1095+
def test_plugin_pool_register_returns_plugin_class(self):
1096+
@plugin_pool.register_plugin
1097+
class DecoratorTestPlugin(CMSPluginBase):
1098+
render_plugin = False
1099+
name = "Test Plugin"
1100+
self.assertIsNotNone(DecoratorTestPlugin)
1101+
10951102

10961103
class FileSystemPluginTests(PluginsTestBaseCase):
10971104
def setUp(self):

0 commit comments

Comments
 (0)