clone cms with menus, make menus standalone app

This commit is contained in:
bruks 2026-09-30 15:27:04 +01:00
commit afb096b7a3
1153 changed files with 318897 additions and 37 deletions

View file

@ -0,0 +1,39 @@
from cms.api import add_plugin
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from .forms import MultiWrapForm
class MultiWrapPlugin(CMSPluginBase):
module = "Multi Wraps"
name = "Multi Wrap"
render_template = 'pluginapp/multiwrap/multiwrap.html'
allow_children = True
child_classes = ["WrapPlugin"]
form = MultiWrapForm
def save_model(self, request, obj, form, change):
response = super().save_model(
request, obj, form, change
)
for x in range(int(form.cleaned_data['create'])):
add_plugin(
placeholder=obj.placeholder,
plugin_type=WrapPlugin.__name__,
language=obj.language,
target=obj,
)
return response
class WrapPlugin(CMSPluginBase):
module = "Multi Wraps"
name = "Wrap"
render_template = 'pluginapp/multiwrap/wrap.html'
parent_classes = ["MultiWrapPlugin"]
allow_children = True
plugin_pool.register_plugin(MultiWrapPlugin)
plugin_pool.register_plugin(WrapPlugin)

View file

@ -0,0 +1,29 @@
from django import forms
from cms.models import CMSPlugin
class MultiWrapForm(forms.ModelForm):
NUM_WRAPS = (
(0, "0"),
(1, "1"),
(2, "2"),
(3, "3"),
(4, "4"),
(5, "5"),
(6, "6"),
(7, "7"),
(8, "8"),
(9, "9"),
(10, "10"),
)
create = forms.ChoiceField(
choices=NUM_WRAPS,
label="Create Wraps",
help_text="Create this number of wraps"
)
class Meta:
model = CMSPlugin
exclude = ('page', 'position', 'placeholder', 'language', 'plugin_type')