Skip to content

Commit 2c174cf

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 2c174cf

File tree

2 files changed

+2
-42
lines changed

2 files changed

+2
-42
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)

taccsite_cms/contrib/taccsite_data_list/cms_plugins.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
from django.utils.translation import gettext_lazy as _
44

55
from taccsite_cms.contrib.constants import TEXT_FOR_NESTED_PLUGIN_CONTENT_SWAP
6-
from taccsite_cms.contrib.helpers import (
7-
concat_classnames,
8-
AbstractMaxChildrenPlugin
9-
)
6+
from taccsite_cms.contrib.helpers import concat_classnames
107

118
from .models import TaccsiteDataList, TaccsiteDataListItem
129
from .constants import ORIENTATION_DICT, TYPE_STYLE_DICT, DENSITY_DICT
@@ -24,7 +21,7 @@ def get_classname(dict, value):
2421
# Plugins
2522

2623
@plugin_pool.register_plugin
27-
class TaccsiteDataListPlugin(CMSPluginBase, AbstractMaxChildrenPlugin):
24+
class TaccsiteDataListPlugin(CMSPluginBase):
2825
"""
2926
Components > "Data List" Plugin
3027
https://confluence.tacc.utexas.edu/x/EiIFDg

0 commit comments

Comments
 (0)