misc: correctly transform acquired placeholders in skeletons (#16537)

This commit is contained in:
Frédéric Péters 2017-05-29 10:06:45 +02:00
parent cdd5d6f92b
commit 7c7e686c32
3 changed files with 22 additions and 4 deletions

View File

@ -792,7 +792,10 @@ class ParentContentCell(CellBase):
if self.page.parent:
parent_page = self.page.parent
elif self.page.slug != 'index':
parent_page = Page.objects.get(slug='index', parent=None)
try:
parent_page = Page.objects.get(slug='index', parent=None)
except Page.DoesNotExist:
return []
else:
return []
cells = CellBase.get_cells(placeholder=self.placeholder, page=parent_page)

View File

@ -171,11 +171,18 @@ def skeleton(request):
else:
raise PermissionDenied()
pages = selected_page.get_parents_and_self()
cells = CellBase.get_cells(page_id=selected_page.id)
extend_with_parent_cells(cells)
# add default ParentContentCells to the page
cells = []
combo_template = settings.COMBO_PUBLIC_TEMPLATES[selected_page.template_name]
for placeholder_key, placeholder in combo_template['placeholders'].items():
if placeholder.get('acquired') is True:
cells.append(ParentContentCell(page=selected_page, placeholder=placeholder_key, order=0))
else:
cells = CellBase.get_cells(page_id=selected_page.id)
pages = selected_page.get_parents_and_self()
combo_template = settings.COMBO_PUBLIC_TEMPLATES[selected_page.template_name]
extend_with_parent_cells(cells)
cell_with_badges = CellBase.get_cells(cell_filter=lambda x: bool(x.get_badge))
ctx = {

View File

@ -134,6 +134,14 @@ def test_page_skeleton(app):
# check {% now %} inside a skeleton_extra_placeholder is not interpreted
assert '{%now' in resp.body
# check cells in footer are present even if there's no redirection page
page.slug = 'index'
page.save()
resp = app.get('/__skeleton__/?source=%s' % urllib.quote('http://127.0.0.1:8999/'))
assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.body
assert not '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.body
assert 'Foobar' in resp.body
def test_subpage_location(app):
Page.objects.all().delete()