Skip to content

Private pages support#423

Merged
thibaudcolas merged 4 commits intomainfrom
private-pages
Mar 6, 2026
Merged

Private pages support#423
thibaudcolas merged 4 commits intomainfrom
private-pages

Conversation

@thibaudcolas
Copy link
Member

Private pages would be helpful for this site. This updates various querysets to make sure they aren’t surfaced unexpectedly.

Copilot AI review requested due to automatic review settings March 6, 2026 13:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
self.assertNotIn('members"', result)
self.assertNotIn('members"', result)
self.assertNotIn('member-only', result)

Copilot uses AI. Check for mistakes.
@thibaudcolas thibaudcolas merged commit 4df8d62 into main Mar 6, 2026
6 checks passed
@thibaudcolas thibaudcolas deleted the private-pages branch March 6, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants