-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix djangocms-versioning draft deletion bug (#214) #215
fix djangocms-versioning draft deletion bug (#214) #215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fscherf Thanks for the pull request!
I've added two comments. Can I ask you to create a test for the behaviour, including the scenario without a message: Delete a draft when a published version is there?
djangocms_alias/admin.py
Outdated
|
||
def delete_model(self, request: HttpRequest, obj: AliasContent): | ||
if obj.alias.contents.filter(language=obj.language).count() == 1: | ||
message = _("Draft deleted. A new empty draft will be created automatically if needed.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message = _("Draft deleted. A new empty draft will be created automatically if needed.") | |
message = _("Alias content for language {} deleted. A new empty alias content will be created if needed.").format(obj.language) |
Not all use cases of djangocms-alias will be in association with versioning. The reference to a draft version does not apply universally. (Sorry, I know I suggested the text in the first place. )
djangocms_alias/admin.py
Outdated
@@ -173,3 +173,13 @@ def has_module_permission(self, request: HttpRequest) -> bool: | |||
"""Hides admin class in admin site overview""" | |||
|
|||
return False | |||
|
|||
def delete_model(self, request: HttpRequest, obj: AliasContent): | |||
if obj.alias.contents.filter(language=obj.language).count() == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that condition is correct. If verisoning is stalled, alias.contents
will give published results only.
if obj.alias.contents.filter(language=obj.language).count() == 1: | |
if obj.alias._default_manager.filter(language=obj.language).count() == 1: |
21a8672
to
ea8db29
Compare
@fsbraun Thanks for your review. I applied both requested changes |
@fsbraun: Is there anything else that I can do? |
@fsbraun: What is the state of this PR? Can it be merged? |
@fscherf LGTM! I will give it a test asap and merge afterwards! |
So, tests should pass again! |
@fscherf I can confirm, that deleting the alias draft does not remove all connected alias plugins. However, I fail to get the new message. Can you point me to where I should be seeing this? |
@fsbraun: Ah! It seems, the message is not shown when using djangocms-versioning, because it overrides the delete method. |
@fsbraun: It works, but the message does not show up in all cases. Is that enough, or do we need to change plans here? |
4f3497c
to
dcb0a9a
Compare
What's the state of this PR? |
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 <[email protected]>
for more information, see https://pre-commit.ci
1706862
to
5eeb8da
Compare
…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 <[email protected]> * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Florian Scherf <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* 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 <[email protected]> * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Florian Scherf <[email protected]> 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 <[email protected]> --------- Signed-off-by: Florian Scherf <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Previously,
djangocms_alias.models.AliasContent.delete
deleted all plugins related toAliasContent.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.