django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
33 stars 29 forks source link

Bug (or feature?): `CMSMenu.get_nodes()` returns URLs of unpublished pages #387

Open jrief opened 3 months ago

jrief commented 3 months ago

How to reproduce:

Expected behaviour:

The culprit is this line of code. In my opinion states should always be [constants.PUBLISHED], because if someone edits a page, he might be confused to get a different menu structure compared to the published version of that page.

fsbraun commented 3 months ago

This is intentional. This allows navigation to not yet published pages using the menu when editing.

Note: The menu renderer of djangocms-versioning will be deprecated in the next version. It has performance issues. The core's menu renderer has been updated to work universally with and without versioning.

If you only want published pages also in edit mode, I suggest having a look here: https://github.com/django-cms/django-cms/blob/develop-4/cms/cms_menus.py

You can modify the if statement in lines 250ff. The default menus can be replaced, just like djangocms-versioning does replace them.

fsbraun commented 3 months ago

It might make sense to separate out the if statement (lines 250ff) into a separate method of the CMSMenu class which would allow customization by subclassing.