8000 fix: return _handle_no_page when page is None by sakhawy · Pull Request #7786 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: return _handle_no_page when page is None #7786

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

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cms/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def test_handle_no_page_for_root_url(self):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse('admin:cms_pagecontent_changelist'))

def test_handle_no_page_for_rool_url_no_homepage(self):
"""
Test details view when visiting root and homepage doesn't exist
"""
create_page("one", "nav_playground.html", "en")
response = self.client.get("/en/")
self.assertEqual(response.status_code, 302)

def test_apphook_not_hooked(self):
"""
Test details view when apphook pool has apphooks, but they're not
Expand Down
6 changes: 4 additions & 2 deletions cms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ def details(request, slug):
return HttpResponseRedirect(redirect_url)

if not page:
# raise 404
_handle_no_page(request)
# raise 404 or redirect to PageContent's
# changelist in the admin if this is a
# request to the root URL
return _handle_no_page(request)

request.current_page = page

Expand Down
0