Skip to content

Commit 43d5ab6

Browse files
committed
GH-75: Remove AbstractMaxChildrenPlugin helper
It does not seem to work, so I am removing it. Without it, lable can be multiple links... that's okay.
1 parent b30cbd0 commit 43d5ab6

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

taccsite_cms/contrib/helpers.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,4 @@ def concat_classnames(classes):
2828

2929

3030

31-
# GH-93, GH-142, GH-133: Upcoming functions here (ease merge conflict, maybe)
32-
33-
34-
35-
# Allow plugins to set max number of nested children
36-
37-
from django.shortcuts import render
38-
39-
# SEE: https://github.com/django-cms/django-cms/issues/5102#issuecomment-597150141
40-
class AbstractMaxChildrenPlugin():
41-
"""
42-
Abstract extension of `CMSPluginBase` that allows setting maximum amount of nested/child plugins.
43-
Usage:
44-
1. Extend this class,
45-
after extending `CMSPluginBase` or a class that extends `CMSPluginBase`.
46-
2. Set `max_children` to desired limit.
47-
"""
48-
49-
max_children = None
50-
51-
def add_view(self, request, form_url='', extra_context=None):
52-
53-
if self.max_children:
54-
# FAQ: Placeholders do not have a parent, only plugins do
55-
if self._cms_initial_attributes['parent']:
56-
num_allowed = len([v for v in self._cms_initial_attributes['parent'].get_children() if v.get_plugin_instance()[0] is not None])
57-
else:
58-
num_allowed = len([v for v in self.placeholder.get_plugins() if v.get_plugin_instance()[0] is not None and v.get_plugin_name() == self.name])
59-
60-
if num_allowed >= self.max_children:
61-
return render(request , "path/to/your/max_reached_template.html", {
62-
'max_children': self.max_children,
63-
})
64-
return super(AbstractMaxChildrenPlugin, self).add_view(request, form_url, extra_context)
65-
66-
67-
6831
# GH-93, GH-142, GH-133: Upcoming functions here (ease merge conflict, maybe)

0 commit comments

Comments
 (0)