0001-misc-inherit-placeholder-options-when-using-parent-c.patch
combo/data/models.py | ||
---|---|---|
1987 | 1987 |
class Meta: |
1988 | 1988 |
verbose_name = _('Same as parent') |
1989 | 1989 | |
1990 |
def get_parents_cells(self, hierarchy): |
|
1990 |
def get_parents_cells(self, hierarchy, leaf):
|
|
1991 | 1991 |
try: |
1992 | 1992 |
pages = [Page.objects.get(slug='index', parent=None)] |
1993 | 1993 |
except Page.DoesNotExist: |
... | ... | |
2010 | 2010 |
cells_by_page[cell.page_id].append(cell) |
2011 | 2011 | |
2012 | 2012 |
cells = cells_by_page[pages[-1].id] |
2013 |
if not leaf.placeholder_options.get(self.placeholder): |
|
2014 |
for page in reversed(pages): |
|
2015 |
# if there's no placeholder options then we copy placeholder |
|
2016 |
# options from parent page. |
|
2017 |
if page.placeholder_options.get(self.placeholder): |
|
2018 |
leaf.placeholder_options[cell.placeholder] = page.placeholder_options.get( |
|
2019 |
self.placeholder |
|
2020 |
) |
|
2021 |
break |
|
2022 | ||
2013 | 2023 |
for page in reversed(pages[:-1]): |
2014 | 2024 |
for i, cell in enumerate(cells): |
2015 | 2025 |
if isinstance(cell, ParentContentCell): |
combo/public/views.py | ||
---|---|---|
211 | 211 |
if not isinstance(cell, ParentContentCell): |
212 | 212 |
continue |
213 | 213 |
idx = cells.index(cell) |
214 |
parent_cells = cell.get_parents_cells(hierarchy=hierarchy[:-1]) |
|
214 |
parent_cells = cell.get_parents_cells(hierarchy=hierarchy[:-1], leaf=hierarchy[-1])
|
|
215 | 215 |
# keep cells that were not already seen and mark cells as seen, |
216 | 216 |
# simultaneously. |
217 | 217 |
parent_cells = [ |
tests/test_public.py | ||
---|---|---|
249 | 249 |
assert resp.text.count('BARFOO') == 1 |
250 | 250 | |
251 | 251 | |
252 |
def test_page_footer_grid_acquisition(app): |
|
253 |
Page.objects.all().delete() |
|
254 |
index_page = Page(title='Home', slug='index', template_name='standard') |
|
255 |
index_page.placeholder_options = {'footer': {'fx_grid_layout': 'fx-grid'}} |
|
256 |
index_page.save() |
|
257 |
cell = TextCell(page=index_page, placeholder='footer', text='BARFOO', order=0) |
|
258 |
cell.save() |
|
259 | ||
260 |
page2 = Page(title='Second', slug='second', template_name='standard') |
|
261 |
page2.save() |
|
262 |
ParentContentCell(page=page2, placeholder='footer', order=0).save() |
|
263 | ||
264 |
page3 = Page(title='Third', slug='third', template_name='standard') |
|
265 |
page3.save() |
|
266 |
ParentContentCell(page=page3, placeholder='footer', order=0).save() |
|
267 | ||
268 |
# check placeholder options are inherited |
|
269 |
resp = app.get(page3.get_online_url()) |
|
270 |
assert resp.pyquery('#footer > .fx-grid > .text-cell') |
|
271 | ||
272 | ||
252 | 273 |
def test_list_of_links_acquisition(app): |
253 | 274 |
Page.objects.all().delete() |
254 | 275 |
index_page = Page(title='Home', slug='index', template_name='standard') |
255 |
- |