-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treebeard error when copying/pasting plugin #4856
Comments
Today I ran into the same problem in CMS-3.2, when using the function Something I don't understand, if someone adds a plugin as child to an existing plugin, then Wouldn't this be the right place to recalculate the |
Hello, The numchild value is calculated by treebeard automatically. |
Sure, the working code is here: https://github.com/jrief/djangocms-cascade/blob/master/cmsplugin_cascade/clipboard/admin.py#L109 I'll try to extract the fundamental parts:
here Now, if I add another instance to the current one, say
then |
@jrief which cms version are you using? textplugincls = plugin_pool.get_plugin('TextPlugin')
textdata = {'body': 'hello there'}
styleplugincls = plugin_pool.get_plugin('StylePlugin')
styledata = {'label': 'root node'}
root_instance = add_plugin(placeholder, styleplugincls, 'en', **styledata)
In [14]: root_instance.numchild
Out[14]: 0
child_instance = add_plugin(placeholder, textplugincls, 'en', target=root_instance, **textdata)
In [17]: root_instance.numchild
Out[17]: 1
In [19]: CMSPlugin.objects.get(pk=root_instance.pk).numchild
Out[19]: 1 |
@jrief I'm closing this ticket now as the original bug has been fixed in both CMS 3.2.1 and 3.1.5. |
All plugins have an internal treebeard field called
numchild
whose value should be how many direct children does the plugin have.Given the structure below:
If I copy the nested Row 1 Column plugin and paste it under another plugin like the style plugin, the new plugin will have its
numchild
attribute set to 0, this means that this new plugin will raise an exception every time I try to add a new plugin to it.Here's a screencast of the issue:
https://drive.google.com/file/d/0B9SwgyV0g1hSS3RLa0ptUEg5U3c/view
Progress:
The text was updated successfully, but these errors were encountered: