Skip to content
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

repeated calls to cms.api.add_plugin does not preserve order #3353

Closed
ojii opened this issue Aug 5, 2014 · 2 comments
Closed

repeated calls to cms.api.add_plugin does not preserve order #3353

ojii opened this issue Aug 5, 2014 · 2 comments

Comments

@ojii
Copy link
Contributor

ojii commented Aug 5, 2014

Using a patched version of https://pypi.python.org/pypi/aldryn-client/0.8.11 (patches make it work with CMS 3 and output a tar.gz instead of multiple files), loading the data causes plugins to be inserted in arbitrary orders (tree-order is not preserved).

Changing the loading code to always refresh all instances used in a add_plugin call did not fix the issue as expected.

What in the end did fix it, was removing three lines from add_plugin: https://github.com/divio/django-cms/blob/3.0.3/cms/api.py#L297-L299

Unfortunately, I was not able to reproduce the issue in a test case yet.

@yakky yakky modified the milestone: 3.0.X Oct 5, 2014
@jrclaramunt
Copy link

To preserve order what i did was to modify the lines you are talking about using as parent the target:

for pl in CMSPlugin.objects.filter(language=language, parent=target, tree_id=target.tree_id, position__gte=new_pos):
            pl.position += 1
            pl.save()

This is working for my project, but unfortunatelly i don't have any tests to support this fix.

@yakky yakky modified the milestones: 3.0.X, 3.0.13 Mar 8, 2015
@mkoistinen mkoistinen modified the milestones: 3.0.X, 3.0.13 Apr 14, 2015
@yakky yakky modified the milestones: 3.0.X, 3.0.16 Sep 2, 2015
@yakky yakky modified the milestones: 3.0.16, Clean up issues & pull requests Nov 24, 2015
@czpython
Copy link
Contributor

Closing. Feel free to create a new ticket if this issue can be reproduced on the latest djangoCMS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants