django-cms: [feat] Without public home page, a 404 error is raised
Summary
If a root page has been created, but is not public (e.g., with djangocms-versioning), a 404 error is raised when the user tries to visit the root page.
While technically correct, a better user experience can be achieved by redirecting the user to the page tree. This is comparable with the user being redirected to a welcome page when no page object is present at all.
Expected behaviour
Either show the welcome page with an explanation (page has been created but is not public) or redirect to the PageContent’s changelist in the admin which shows the page tree and allows actions like preview or publish.
Actual behaviour
404
Environment
- django CMS version: 4.1.0
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Reactions: 1
- Comments: 18 (18 by maintainers)
Sorry, I did not see this. It’s a call to make between two sides:
page_permissions.user_can_change_at_least_one_page) which nudges me to not checking permissions.urls.pyand redirecting to the 404 view.My call would be to not check permissions. The second point fails to convince me. @marksweb Do you have an opinion on this?
Well spotted! Interestingly, the original call in line 29 did have the return. Can you create a PR?
@erkesado Sure!
Mongolian is great, of course, but I fear there has not been done much. The more I would appreciate any time you spent on this. To make this feasible I would suggest not to go for 100% coverage in the first step… Are you on our slack channel (https://django-cms.org/slack)?
Ruff is the linter we use and the return code of 1 indicates that it found a linting issue.
Try running
ruff cms --fix.Hi @fsbraun! Thank you very much. With your generous help, the issue has been fixed, and the related test codes have been added. There is only 1 failure left in the test. In
cms/tests/test_static_analysis.pyfile, thetest_rufffails and throws the following error:But how does it relate to my change in the code? Please, give me a clue 🔢
@fsbraun, @marksweb let me fix this issue.