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

djangocms-versioning draft deletion causes plugins to disappear from pages #214

Closed
fscherf opened this issue Jan 16, 2024 · 9 comments
Closed

Comments

@fscherf
Copy link
Contributor

fscherf commented Jan 16, 2024

When I use djangocms-alias with djangocms-versioning and I delete a draft of an alias, the alias does not get reset to the previous version on the pages using it. Instead, it gets removed entirely from all pages.

Steps to reproduce:

  1. Create a Page and publish it
  2. Create a Content Alias on that page and publish it
  3. Create a new draft for the Content Alias
  4. Delete the draft

I think the problem is rooted in this line in models.AliasContent.delete. From the code, it looks like this is wanted behavior because it deliberately deletes all plugins using the deleted Alias Content. Hence I am not sure how to fix it (just removing it works for me).

I use django-cms 4.1, and I was able to reproduces this behavior in all djangocms-alias versions I tried, including the latest master.

@fsbraun
Copy link
Member

fsbraun commented Jan 16, 2024

Just to clarify: how do you delete the draft alias?

@fscherf
Copy link
Contributor Author

fscherf commented Jan 16, 2024

@fsbraun: i went to the preview of the alias, clicked on "Versions" in the top-bar, and clicked on the trash icon of the draft in the table of listed versions

@fsbraun
Copy link
Member

fsbraun commented Jan 16, 2024

From the code I fear the plugins are even deleted if there are alias contents available in other languages. To me it only makes sense to delete thos plugins if the whole Alias is deleted.

@fsbraun
Copy link
Member

fsbraun commented Jan 17, 2024

Hm, I think this is a serious bug. It would also imply that an alias plugin is removed from a published page. I can only assume that the following happened:

  • Someone deleted the last AliasContent of an alias.
  • Viewed the page where the alias used, triggering an automatic creation of a new draft
  • Got a bad user experience, since the just deleted draft magically reappeared.

One solution for me would be to remove the mechanism and to add a warning message (using the message framework) which would trigger if the last alias content of a language was deleted.

@fscherf Would you be interested to create a pull request?

@fscherf
Copy link
Contributor Author

fscherf commented Jan 17, 2024

@fsbraun: Yes! Alias plugins are disappearing from published pages definitely.

Ok. That would mean, the deletion of an AliasContent object wouldn't trigger the deletion of cms plugins anymore. What do we do with orphaned cms plugins that point to no longer existing AliasContents then?

Yes, I would be interested in opening a pull-request, once we decided on how to fix this issue.

@fsbraun
Copy link
Member

fsbraun commented Jan 17, 2024

They'll point to an Alias object (which is still there). Upon rendering the alias plugins with no AliasContent for the selected language, they should be treated as empty.

Deleting Alias objects should automatically trigger a cascade to either also delete the alias plugins (if possible) or deny deleting the alias.

For now, I would be fine with the warning through the message framework. In the alias's admin delete view:

    if <last content object of language deleted>:
        message = _('Draft deleted. A new empty draft will be created automatically if needed.')  # Or something better
        self.message_user(request, message, level=messages.WARNING)

fscherf added a commit to fscherf/djangocms-alias that referenced this issue Jan 29, 2024
Previously, `djangocms_alias.models.AliasContent.delete` deleted all plugins
related to `AliasContent.alias`, with the same language. Drafts and previously
published versions included.
This meant that the deletion of a draft resulted in plugins disappearing from
published pages.

This patch removes the mechanism entirely and instead adds a warning, notifying
the user that the last version or translation of a language got deleted.

Signed-off-by: Florian Scherf <mail@florianscherf.de>
fscherf added a commit to fscherf/djangocms-alias that referenced this issue Jan 30, 2024
Previously, `djangocms_alias.models.AliasContent.delete` deleted all plugins
related to `AliasContent.alias`, with the same language. Drafts and previously
published versions included.
This meant that the deletion of a draft resulted in plugins disappearing from
published pages.

This patch removes the mechanism entirely and instead adds a warning, notifying
the user that the last version or translation of a language got deleted.

Signed-off-by: Florian Scherf <mail@florianscherf.de>
marksweb pushed a commit to fscherf/djangocms-alias that referenced this issue Feb 13, 2024
Previously, `djangocms_alias.models.AliasContent.delete` deleted all plugins
related to `AliasContent.alias`, with the same language. Drafts and previously
published versions included.
This meant that the deletion of a draft resulted in plugins disappearing from
published pages.

This patch removes the mechanism entirely and instead adds a warning, notifying
the user that the last version or translation of a language got deleted.

Signed-off-by: Florian Scherf <mail@florianscherf.de>
marksweb pushed a commit to fscherf/djangocms-alias that referenced this issue Mar 9, 2024
Previously, `djangocms_alias.models.AliasContent.delete` deleted all plugins
related to `AliasContent.alias`, with the same language. Drafts and previously
published versions included.
This meant that the deletion of a draft resulted in plugins disappearing from
published pages.

This patch removes the mechanism entirely and instead adds a warning, notifying
the user that the last version or translation of a language got deleted.

Signed-off-by: Florian Scherf <mail@florianscherf.de>
fsbraun pushed a commit that referenced this issue Mar 10, 2024
* fix djangocms-versioning draft deletion bug (#214)

Previously, `djangocms_alias.models.AliasContent.delete` deleted all plugins
related to `AliasContent.alias`, with the same language. Drafts and previously
published versions included.
This meant that the deletion of a draft resulted in plugins disappearing from
published pages.

This patch removes the mechanism entirely and instead adds a warning, notifying
the user that the last version or translation of a language got deleted.

Signed-off-by: Florian Scherf <mail@florianscherf.de>

* ci: auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Florian Scherf <mail@florianscherf.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@fscherf
Copy link
Contributor Author

fscherf commented Mar 13, 2024

@fsbraun Thanks for merging! When will the fix be released?

@fsbraun
Copy link
Member

fsbraun commented Mar 13, 2024

I hope within the next 2 weeks.

@fsbraun
Copy link
Member

fsbraun commented Mar 29, 2024

Published with 2.0.1

@fsbraun fsbraun closed this as completed Mar 29, 2024
fscherf added a commit to fscherf/djangocms-alias that referenced this issue Apr 9, 2024
…cms#215)

* fix djangocms-versioning draft deletion bug (django-cms#214)

Previously, `djangocms_alias.models.AliasContent.delete` deleted all plugins
related to `AliasContent.alias`, with the same language. Drafts and previously
published versions included.
This meant that the deletion of a draft resulted in plugins disappearing from
published pages.

This patch removes the mechanism entirely and instead adds a warning, notifying
the user that the last version or translation of a language got deleted.

Signed-off-by: Florian Scherf <mail@florianscherf.de>

* ci: auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Florian Scherf <mail@florianscherf.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
FinalAngel pushed a commit that referenced this issue Apr 11, 2024
* fix djangocms-versioning draft deletion bug (#214) (#215)

* fix djangocms-versioning draft deletion bug (#214)

Previously, `djangocms_alias.models.AliasContent.delete` deleted all plugins
related to `AliasContent.alias`, with the same language. Drafts and previously
published versions included.
This meant that the deletion of a draft resulted in plugins disappearing from
published pages.

This patch removes the mechanism entirely and instead adds a warning, notifying
the user that the last version or translation of a language got deleted.

Signed-off-by: Florian Scherf <mail@florianscherf.de>

* ci: auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Florian Scherf <mail@florianscherf.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* tests: requirements: django42: fix broken djangocms-versioning URL

Signed-off-by: Florian Scherf <mail@florianscherf.de>

---------

Signed-off-by: Florian Scherf <mail@florianscherf.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants