diff --git a/combo/apps/kb/models.py b/combo/apps/kb/models.py index 59b39a34..5f3208cf 100644 --- a/combo/apps/kb/models.py +++ b/combo/apps/kb/models.py @@ -15,6 +15,7 @@ # along with this program. If not, see . import datetime +import itertools from django.db import models from django.utils import timezone @@ -42,5 +43,8 @@ class LatestPageUpdatesCell(CellBase): pages = self.root_page.get_descendants_and_me() else: pages = Page.objects.all() - extra_context['pages'] = pages.order_by('-last_update_timestamp')[:self.limit] + user = self.get_concerned_user(context) + extra_context['pages'] = itertools.islice( + (x for x in pages.order_by('-last_update_timestamp') if x.is_visible(user=user)), + self.limit) return extra_context diff --git a/tests/test_kb.py b/tests/test_kb.py index 4e126d72..edde9174 100644 --- a/tests/test_kb.py +++ b/tests/test_kb.py @@ -17,6 +17,8 @@ import pytest import re +from django.test.client import RequestFactory + from combo.data.models import CellBase, Page, TextCell from combo.apps.kb.models import LatestPageUpdatesCell @@ -135,3 +137,29 @@ def test_updated_pages_cell_root_page(): Page.objects.get(slug='page-2').delete() cell = CellBase.get_cells(slug='me')[0] # reload cell assert cell.render(ctx).count('