Allow a limit on placeholder direct children

35 views
Skip to first unread message

Gerben van Eerten

unread,
Apr 29, 2020, 3:39:00 PM4/29/20
to django CMS developers
In the current implementation I can set a limit on the number of plugins in a placeholder. This limitation is for the total count of plugins in the placeholder, not the direct children of the placeholder.

I have a placeholder which should only allow 1 item, but it may contain a plugin which has multiple children. If I set the 'limit':{'global':1}, I can add one plugin which allows children but I can not add plugins to that plugin anymore.

I would have expected that the limit only counts for the direct children of a placeholder. If this is the expected behavior, than this is a bug report. If the limit should by design also count for plugins which allow for children, than this is a feature request.

Proposal:
Add a children_limits to the settings CMS_PLACEHOLDER_CONF
Add a function get_child_plugins to cms/models/placeholdermodel.py which only selects direct children.
Modify the has_reached_plugin_limit function in cms/utils/plugins.py to check for limits on direct children count
Modify cms/admin/forms.py PluginAddValidationForm.clean function to include a reference to the call to has_reached_plugin_limit
Modify cms/admin/placeholderadmin.py move_plugin function to include a reference to the call to has_reached_plugin_limit
Add test case tocms/tests/test_placeholder.py
Add test case tocms/tests/test_admin.py



Reply all
Reply to author
Forward
0 new messages