From 3f9bf2de6ac5219db8dd8010601113a709da8645 Mon Sep 17 00:00:00 2001 From: Julian Dehm Date: Tue, 31 Oct 2023 11:06:01 +0100 Subject: [PATCH] apps/contrib: hide unpublished and password protected pages from search results fixes #851, #877 --- apps/contrib/elasticsearch.py | 2 ++ changelog/_1113.md | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelog/_1113.md diff --git a/apps/contrib/elasticsearch.py b/apps/contrib/elasticsearch.py index 133f998b..9420684a 100644 --- a/apps/contrib/elasticsearch.py +++ b/apps/contrib/elasticsearch.py @@ -40,6 +40,8 @@ def _get_results_from_hits(self, hits): break for obj in self.query_compiler.queryset.filter(pk__in=pks): + if not obj.live or obj.get_view_restrictions().exists(): + continue results[str(obj.pk)] = obj if self._score_field: diff --git a/changelog/_1113.md b/changelog/_1113.md new file mode 100644 index 00000000..0f1555ab --- /dev/null +++ b/changelog/_1113.md @@ -0,0 +1,3 @@ +### Changed + +- Pages which are not published or password protected are excluded from the search results (#851, #877)