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

copy_relations() does not work for relations between cmsplugins #4143

Closed
philippze opened this Issue Jun 2, 2015 · 9 comments

Comments

Projects
None yet
6 participants
@philippze
Contributor

philippze commented Jun 2, 2015

In the docs, there's a recipe for handling relations in custom plugins.

However, this will not work when we deal with relations from one cmsplugin to another cmsplugin.

I've written four unittests here. Two pass and show that the docs is correct in usual cases. Two fail and show that it's not so simple for relations between cmsplugins.

Maybe one could mention this in the docs.

I'm now writing a little module that solves the problem for ManyToManyFields. Existing solutions welcome!

@yakky

This comment has been minimized.

Contributor

yakky commented Jun 7, 2015

Thanks for the awesome tests and a very well described issue.
The problem with copy_relations between plugins is that while the copy_relations in philippze@658e67f#diff-f813663252f41cc6f43485a6b06e7caeR58 will work when copying the PluginModelWithM2MToModel, there is no (general) way for the target plugin to change the reference from the "draft" to the "live" version of itself in the referencing plugins.
I think we can just document this.

@yakky yakky added this to the 3.1.x milestone Jun 7, 2015

@yakky yakky modified the milestones: 3.1.1, 3.1.x Jun 14, 2015

@yakky yakky modified the milestones: 3.1.x, 3.1.3 Jul 3, 2015

@evildmp

This comment has been minimized.

Contributor

evildmp commented Jul 20, 2015

@yakky @philippze Should we not also incorporate at least the passing tests and keep this open until a more general solution is available?

evildmp added a commit that referenced this issue Jul 20, 2015

Addresses #4143
Note this is not a fix.
@yakky

This comment has been minimized.

Contributor

yakky commented Jul 21, 2015

@philippze I totally second @evildmp proposal. Could you open a PR?

@yakky yakky modified the milestones: 3.1.3, 3.1.x Jul 21, 2015

@yakky yakky modified the milestones: 3.1.x, 3.1.4 Sep 2, 2015

@sergei-maertens

This comment has been minimized.

sergei-maertens commented Nov 8, 2015

Another use this case that fits this issue is re-using plugin content.

We have a specific use case where the end-user adds a 'Story' plugin to a certain page. It has some images, a bit of text, and nested plugins for the body of the content.

On the homepage, they need to be able to refer to this very same story, and if the initial story page (and plugin) gets updated, the homepage version has to be synced as well.

Currently this is solved by letting the HomepageStoryPlugin link (via FK) to the draft version of the StoryPlugin, but that obviously has its drawbacks.

@yakky yakky removed this from the 3.1.4 milestone Nov 17, 2015

@yakky yakky modified the milestones: 3.3, 3.1.4 Nov 17, 2015

@mkoistinen

This comment has been minimized.

Contributor

mkoistinen commented Jan 30, 2016

@philippze someone else had a similar need and I put together a sample plugin for them. Perhaps this will help you too? https://gist.github.com/mkoistinen/403a81c05b4b8f783c74 and a video demo of this plugin in action: http://cl.ly/332q3R42202X/draft-public-plugin-demo.m4v

@philippze

This comment has been minimized.

Contributor

philippze commented Mar 23, 2016

Hi @mkoistinen Thanks for this useful hint! I've started to write a djangocms-relations plugin in the Christmas holidays, but unfortunately did not have any time to continue since. The plugin starts with the same idea as the HighWaterMarkPlugin. In case anyone would like to contribute, they're welcome here

@mkoistinen mkoistinen modified the milestones: 3.3.1, 3.3.0.RC1 May 16, 2016

@mkoistinen mkoistinen modified the milestones: 3.3.0, 3.3.1 May 16, 2016

@mkoistinen

This comment has been minimized.

Contributor

mkoistinen commented May 16, 2016

I've been seeing similar "issues" lately as people seem to think that CMSPlugins should be the basis of all business logic. I think we can probably do a lot with some clearer guidance in the documents about what CMSPlugins are for and what they're not for.

@philippze

This comment has been minimized.

Contributor

philippze commented May 18, 2016

I'm now setting a deadline for myself. My module that simplifies relations with CMSPlugins should be ready in 2 weeks.

@mkoistinen mkoistinen modified the milestones: 3.3.0, 3.3.1 May 23, 2016

@czpython czpython removed this from the 3.3.1 milestone Jul 11, 2016

@czpython

This comment has been minimized.

Contributor

czpython commented Feb 24, 2017

Closing as the original issue was addressed in 31ac39f and #4466

@czpython czpython closed this Feb 24, 2017

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