misc: inherit placeholder options when using parent content cells (#68679)
This commit is contained in:
parent
496dec06c9
commit
c81c303e0a
|
@ -1987,7 +1987,7 @@ class ParentContentCell(CellBase):
|
|||
class Meta:
|
||||
verbose_name = _('Same as parent')
|
||||
|
||||
def get_parents_cells(self, hierarchy):
|
||||
def get_parents_cells(self, hierarchy, leaf):
|
||||
try:
|
||||
pages = [Page.objects.get(slug='index', parent=None)]
|
||||
except Page.DoesNotExist:
|
||||
|
@ -2010,6 +2010,16 @@ class ParentContentCell(CellBase):
|
|||
cells_by_page[cell.page_id].append(cell)
|
||||
|
||||
cells = cells_by_page[pages[-1].id]
|
||||
if not leaf.placeholder_options.get(self.placeholder):
|
||||
for page in reversed(pages):
|
||||
# if there's no placeholder options then we copy placeholder
|
||||
# options from parent page.
|
||||
if page.placeholder_options.get(self.placeholder):
|
||||
leaf.placeholder_options[cell.placeholder] = page.placeholder_options.get(
|
||||
self.placeholder
|
||||
)
|
||||
break
|
||||
|
||||
for page in reversed(pages[:-1]):
|
||||
for i, cell in enumerate(cells):
|
||||
if isinstance(cell, ParentContentCell):
|
||||
|
|
|
@ -211,7 +211,7 @@ def extend_with_parent_cells(cells, hierarchy):
|
|||
if not isinstance(cell, ParentContentCell):
|
||||
continue
|
||||
idx = cells.index(cell)
|
||||
parent_cells = cell.get_parents_cells(hierarchy=hierarchy[:-1])
|
||||
parent_cells = cell.get_parents_cells(hierarchy=hierarchy[:-1], leaf=hierarchy[-1])
|
||||
# keep cells that were not already seen and mark cells as seen,
|
||||
# simultaneously.
|
||||
parent_cells = [
|
||||
|
|
|
@ -249,6 +249,27 @@ def test_page_footer_acquisition(app):
|
|||
assert resp.text.count('BARFOO') == 1
|
||||
|
||||
|
||||
def test_page_footer_grid_acquisition(app):
|
||||
Page.objects.all().delete()
|
||||
index_page = Page(title='Home', slug='index', template_name='standard')
|
||||
index_page.placeholder_options = {'footer': {'fx_grid_layout': 'fx-grid'}}
|
||||
index_page.save()
|
||||
cell = TextCell(page=index_page, placeholder='footer', text='BARFOO', order=0)
|
||||
cell.save()
|
||||
|
||||
page2 = Page(title='Second', slug='second', template_name='standard')
|
||||
page2.save()
|
||||
ParentContentCell(page=page2, placeholder='footer', order=0).save()
|
||||
|
||||
page3 = Page(title='Third', slug='third', template_name='standard')
|
||||
page3.save()
|
||||
ParentContentCell(page=page3, placeholder='footer', order=0).save()
|
||||
|
||||
# check placeholder options are inherited
|
||||
resp = app.get(page3.get_online_url())
|
||||
assert resp.pyquery('#footer > .fx-grid > .text-cell')
|
||||
|
||||
|
||||
def test_list_of_links_acquisition(app):
|
||||
Page.objects.all().delete()
|
||||
index_page = Page(title='Home', slug='index', template_name='standard')
|
||||
|
|
Loading…
Reference in New Issue