Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds private page support by ensuring that Wagtail's .public() queryset filter is applied across all public-facing page queries. This prevents pages with view restrictions (e.g., login-required) from appearing in search results, navigation, previous/next page links, and hreflang tags.
Changes:
- Adds
.public()to page querysets in search views, header/hreflang template tags, and the content page's previous/next navigation context. - Adds tests verifying that private pages are excluded from the header navigation and previous/next page links.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
apps/search/views.py |
Adds .public() filter to both the HTML search and JSON autocomplete search querysets |
apps/core/templatetags/core_tags.py |
Adds .public() to the header navigation queryset and the hreflangs translation queryset |
apps/core/models/content.py |
Adds .public() to the previous/next page navigation queryset in ContentPage.get_context() |
apps/core/tests/test_header.py |
Adds test verifying private pages and their descendants are excluded from the header nav |
apps/core/tests/test_previous_page_and_next_page.py |
Adds test verifying private pages are excluded from previous/next page navigation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| template = Template("{% load core_tags %}{% header %}") | ||
| result = template.render(Context({})) | ||
|
|
||
| self.assertNotIn('members"', result) |
There was a problem hiding this comment.
The test docstring says "Descendants of private pages should also be excluded from the nav," but the only assertion (assertNotIn('members"', result)) only verifies the private parent page (members) is absent. It does not verify that the child page (member-only) is also excluded. Consider adding an explicit assertion like self.assertNotIn('member-only', result) to fully validate the descendant exclusion behavior.
| self.assertNotIn('members"', result) | |
| self.assertNotIn('members"', result) | |
| self.assertNotIn('member-only', result) |
1526e10 to
9dcf114
Compare
Private pages would be helpful for this site. This updates various querysets to make sure they aren’t surfaced unexpectedly.