Skip to content

Commit

Permalink
Merge 6da1c73 into d503b0f
Browse files Browse the repository at this point in the history
  • Loading branch information
vxsx committed Nov 23, 2017
2 parents d503b0f + 6da1c73 commit 88fe09a
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 1 deletion.
Empty file.
41 changes: 41 additions & 0 deletions cms/test_utils/project/pluginapp/plugins/multiwrap/cms_plugins.py
@@ -0,0 +1,41 @@
from cms.models import CMSPlugin
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(MultiWrapPlugin, self).save_model(
request, obj, form, change
)
for x in range(int(form.cleaned_data['create'])):
col = CMSPlugin(
parent=obj,
placeholder=obj.placeholder,
language=obj.language,
position=CMSPlugin.objects.filter(parent=obj).count(),
plugin_type=WrapPlugin.__name__
)
col.save()
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)
29 changes: 29 additions & 0 deletions cms/test_utils/project/pluginapp/plugins/multiwrap/forms.py
@@ -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')
Empty file.
@@ -0,0 +1,4 @@
{% load cms_tags %}
{% for plugin in instance.child_plugin_instances %}
{% render_plugin plugin %}
{% endfor %}
@@ -0,0 +1,7 @@
{% load cms_tags %}
<div class="inner-wrap" style="padding: 40px;">
inner-wrap
{% for plugin in instance.child_plugin_instances %}
{% render_plugin plugin %}
{% endfor %}
</div>
@@ -0,0 +1,4 @@
{% load cms_tags %}
{% for plugin in instance.child_plugin_instances %}
{% render_plugin plugin %}
{% endfor %}
@@ -0,0 +1,6 @@
{% load cms_tags %}
<div class="inner-wrap">
{% for plugin in instance.child_plugin_instances %}
{% render_plugin plugin %}
{% endfor %}
</div>
42 changes: 42 additions & 0 deletions cms/tests/frontend/integration/add-multiple-plugins.js
@@ -0,0 +1,42 @@
var helpers = require('djangocms-casper-helpers');
var globals = helpers.settings;
var casperjs = require('casper');
var cms = helpers(casperjs);

casper.test.setUp(function(done) {
casper
.start()
.then(cms.login())
.then(cms.addPage({ title: 'First page' }))
.run(done);
});

casper.test.tearDown(function(done) {
casper.start().then(cms.removePage()).then(cms.logout()).run(done);
});

casper.test.begin('Tooltip is correct after adding multiple plugins', function(test) {
casper
.start(globals.editUrl)
.then(cms.addPlugin({
type: 'MultiWrapPlugin',
content: {
id_create: 1
}
}))
.wait(1000, function () {
var plugin = this.getElementBounds('.inner-wrap');

this.mouse.move(plugin.left + plugin.width / 2, plugin.top + plugin.height / 2);
})
.then(function () {
test.assertVisible('.cms-tooltip');
test.assertSelectorHasText(
'.cms-tooltip span',
'Placeholder_Content_1: Wrap'
);
})
.run(function() {
test.done();
});
});
1 change: 1 addition & 0 deletions cms/toolbar/utils.py
Expand Up @@ -107,6 +107,7 @@ def collect_plugin_data(plugin):
'cms_toolbar': toolbar,
}
tree_structure.append(template.render(context))
tree_data.reverse()
return json.dumps({'html': '\n'.join(tree_structure), 'plugins': tree_data})


Expand Down
3 changes: 2 additions & 1 deletion gulpfile.js
Expand Up @@ -66,7 +66,8 @@ var INTEGRATION_TESTS = [
'permissions',
'logout',
'clipboard',
'link-plugin-content-mode'
'link-plugin-content-mode',
'add-multiple-plugins'
],
[
'pageTypes',
Expand Down
1 change: 1 addition & 0 deletions manage.py
Expand Up @@ -48,6 +48,7 @@ def __getitem__(self, item):
'cms.test_utils.project.placeholderapp',
'cms.test_utils.project.pluginapp.plugins.link',
'cms.test_utils.project.pluginapp.plugins.multicolumn',
'cms.test_utils.project.pluginapp.plugins.multiwrap',
'cms.test_utils.project.pluginapp.plugins.style',
'cms.test_utils.project.pluginapp.plugins.manytomany_rel',
'cms.test_utils.project.pluginapp.plugins.extra_context',
Expand Down
1 change: 1 addition & 0 deletions testserver.py
Expand Up @@ -116,6 +116,7 @@ def update(self, whatever):
'djangocms_text_ckeditor',
'cms.test_utils.project.pluginapp.plugins.link',
'cms.test_utils.project.pluginapp.plugins.multicolumn',
'cms.test_utils.project.pluginapp.plugins.multiwrap',
'cms.test_utils.project.pluginapp.plugins.style',
'cms.test_utils.project.placeholderapp',
],
Expand Down

0 comments on commit 88fe09a

Please sign in to comment.