emencia / cmsplugin-blocks

A set of DjangoCMS plugins for structured contents in CMS pages
https://cmspluginblocks.readthedocs.io/
MIT License
2 stars 0 forks source link

Plugin images are lost when publishing #22

Closed sveetch closed 1 year ago

sveetch commented 1 year ago

Describe the bug When publishing a page, blocks plugins can lost their images sources.

To Reproduce Steps to reproduce the behavior:

  1. Create a two Card plugins in a page, both with images;
  2. Publish the page;
  3. Go back to page edition:
  4. Edit only one of the Card plugin, change its images;
  5. Publish the page again;
  6. The card plugin which has not been edited has lost its image source;

Expected behavior Image sources from plugin should never been removed if user does not have explicitly cleared them.

Desktop (If applicable):

Versions:

Additional context This is related to the DjangoCMS way to manage published/draft version, published page use cloned plugin from draft and the previous ones are deleted, which trigger the post_delete signal. The receiver auto_purge_files_on_delete can not know about this cloning method and so legitimately remove files during deletion, even files are used in clones plugin in published page.

I've digged a little on this but DjangoCMS does not seems to pass any useful argument to receiver to know if file purge should be done or not. For true this would be possible but would require making additional queries to retrieved involved object and pages to determine if file is used or not, this seems bloated.

At this point, the only workaround is to remove receiver auto_purge_files_on_delete from all plugins.

sveetch commented 1 year ago

Receiver auto_purge_files_on_delete has been removed from all plugin models in 1.1.0-pre.3