applications: card cell dependencies to pages (#86520)

This commit is contained in:
Lauréline Guérin 2024-02-05 14:30:07 +01:00
parent f74e768a11
commit 81b27151a3
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 13 additions and 0 deletions

View File

@ -1096,6 +1096,11 @@ class WcsCardCell(CardMixin, CellBase):
if not value:
continue
yield from get_wcs_dependencies_from_template(str(value))
if cell.get('page') not in ['', None]:
try:
yield Page.objects.get(pk=cell['page'])
except Page.DoesNotExist:
pass
def check_validity(self):
if self.get_related_card_path():

View File

@ -661,6 +661,14 @@ def test_page_dependencies_card_cell(mock_send):
cell.mark_as_invalid(reason_code='foobar')
assert card_dep not in page.get_dependencies()
other_page = Page.objects.create(title='Other Test', slug='other-test', template_name='standard')
cell.mark_as_valid()
cell.custom_schema = {'cells': [{'page': other_page.pk}]}
cell.save()
assert other_page in page.get_dependencies()
cell.mark_as_invalid(reason_code='foobar')
assert other_page not in page.get_dependencies()
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_page_dependencies_category_cell(mock_send):