Closed fscherf closed 4 months ago
Just to clarify: how do you delete the draft alias?
@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
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.
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:
AliasContent
of an alias.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?
@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.
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)
@fsbraun Thanks for merging! When will the fix be released?
I hope within the next 2 weeks.
Published with 2.0.1
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:
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.