search: index all cell's external links (#41600)
This commit is contained in:
parent
9c45076ded
commit
efc784d4e1
|
@ -84,7 +84,7 @@ def index_site():
|
|||
|
||||
for link_data in cell.get_external_links_data():
|
||||
# index external links
|
||||
indexed_cell = external_urls.get(indexed_cell.url)
|
||||
indexed_cell = external_urls.get(link_data.get('url'))
|
||||
if indexed_cell is None:
|
||||
# create an entry for that link.
|
||||
indexed_cell = IndexedCell(
|
||||
|
@ -101,7 +101,7 @@ def index_site():
|
|||
else:
|
||||
# if that link already exists, add detailed texts
|
||||
indexed_cell.indexed_text += ' ' + link_data['title']
|
||||
indexed_cell.indexed_text += ' ' + link_data.get('text') or ''
|
||||
indexed_cell.indexed_text += ' ' + (link_data.get('text') or '')
|
||||
indexed_cell.save()
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@ from combo.apps.wcs.models import (WcsFormCell, WcsCurrentFormsCell,
|
|||
WcsFormsOfCategoryCell, WcsCurrentDraftsCell, WcsCategoryCell,
|
||||
TrackingCodeInputCell, BackofficeSubmissionCell, WcsCareFormsCell)
|
||||
|
||||
from combo.apps.search.models import SearchCell, IndexedCell
|
||||
from combo.apps.search.utils import index_site, search_site
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
from combo.utils import NothingInCacheException
|
||||
|
||||
from .test_manager import login
|
||||
|
@ -1337,3 +1342,36 @@ def test_hourly():
|
|||
assert check_validity.call_args_list == [mock.call()]
|
||||
else:
|
||||
assert hasattr(klass, 'check_validity') is False
|
||||
|
||||
|
||||
@wcs_present
|
||||
def test_search_external_forms_links(context):
|
||||
|
||||
page = Page(title='xxx', slug='test_forms_of_category_cell_search',
|
||||
template_name='standard')
|
||||
page.save()
|
||||
|
||||
cell = SearchCell(page=page, _search_services={'data': ['_text']}, order=0)
|
||||
cell.save()
|
||||
|
||||
index_site()
|
||||
request = RequestFactory().get('/')
|
||||
request.user = AnonymousUser()
|
||||
hits = search_site(request, 'form')
|
||||
assert len(hits) == 0
|
||||
|
||||
cell = WcsFormsOfCategoryCell(page=page, placeholder='content', order=1)
|
||||
cell.category_reference = 'default:test-9'
|
||||
cell.ordering = 'alpha'
|
||||
cell.save()
|
||||
context['synchronous'] = True # to get fresh content
|
||||
result = cell.render(context)
|
||||
assert 'form title' in result and 'a second form title' in result
|
||||
assert 'http://127.0.0.1:8999/form-title/tryauth' in result
|
||||
assert 'http://127.0.0.1:8999/a-second-form-title/tryauth' in result
|
||||
|
||||
index_site()
|
||||
request = RequestFactory().get('/')
|
||||
request.user = AnonymousUser()
|
||||
hits = search_site(request, 'form')
|
||||
assert len(hits) == 2
|
||||
|
|
Loading…
Reference in New Issue