search: do not consider page with sub_slug (#40108)
This commit is contained in:
parent
0215e2424b
commit
3662751240
|
@ -44,7 +44,7 @@ def index_site():
|
|||
IndexedCell.objects.all().delete()
|
||||
external_urls = {}
|
||||
for klass in CellBase.get_cell_classes():
|
||||
for cell in klass.objects.filter(page__snapshot__isnull=True).exclude(placeholder__startswith='_'):
|
||||
for cell in klass.objects.filter(page__snapshot__isnull=True, page__sub_slug='').exclude(placeholder__startswith='_'):
|
||||
cell_type = ContentType.objects.get_for_model(cell)
|
||||
indexed_cell = IndexedCell(cell_type=cell_type, cell_pk=cell.id)
|
||||
try:
|
||||
|
|
|
@ -510,3 +510,21 @@ def test_restricted_search(app):
|
|||
assert len(hits) == 0
|
||||
hits = search_site(request, 'barfoo')
|
||||
assert len(hits) == 1
|
||||
|
||||
|
||||
def test_no_sub_slug_search(app):
|
||||
page = Page(title='example page', slug='example-page')
|
||||
page.save()
|
||||
TextCell(page=page, text='<p>foobar</p>', order=0, public=True).save()
|
||||
page = Page(title='example page with sub_slug', slug='sub-slugged-page',
|
||||
sub_slug='(?P<foo>\d+)')
|
||||
page.save()
|
||||
TextCell(page=page, text='<p>barfoo</p>', order=0, public=True).save()
|
||||
|
||||
request = RequestFactory().get('/')
|
||||
request.user = AnonymousUser()
|
||||
index_site()
|
||||
hits = search_site(request, 'foobar')
|
||||
assert len(hits) == 1
|
||||
hits = search_site(request, 'barfoo')
|
||||
assert len(hits) == 0
|
||||
|
|
Loading…
Reference in New Issue