misc: remove duplicated code (#67254)
This commit is contained in:
parent
4ed8ebcf21
commit
c240f32a66
|
@ -345,16 +345,6 @@ def skeleton(request):
|
|||
extend_with_parent_cells(cells, hierarchy=pages)
|
||||
mark_duplicated_slugs(cells)
|
||||
|
||||
# mark duplicated slugs to avoid using them in HTML id attributes.
|
||||
cell_by_slugs = {}
|
||||
for cell in cells:
|
||||
if cell.slug not in cell_by_slugs:
|
||||
cell_by_slugs[cell.slug] = []
|
||||
cell_by_slugs[cell.slug].append(cell)
|
||||
for slug_cells in cell_by_slugs.values():
|
||||
for cell in slug_cells:
|
||||
cell.use_slug_as_id = bool(len(slug_cells) == 1)
|
||||
|
||||
ctx = {
|
||||
'page': selected_page,
|
||||
'page_cells': cells,
|
||||
|
|
|
@ -356,12 +356,17 @@ def test_page_skeleton(app):
|
|||
resp = app.get('/__skeleton__/?source=%s' % quote('http://example.com/foo/bar'), status=403)
|
||||
|
||||
# check with a footer cell
|
||||
cell = TextCell(page=page, placeholder='footer', text='Foobar', order=0)
|
||||
cell.save()
|
||||
TextCell.objects.create(page=page, placeholder='footer', text='Foobar', order=0)
|
||||
TextCell.objects.create(page=page, placeholder='content', text='Foobar', slug='unique', order=1)
|
||||
TextCell.objects.create(page=page, placeholder='content', text='Foobar', slug='dup', order=2)
|
||||
TextCell.objects.create(page=page, placeholder='content', text='Foobar', slug='dup', order=3)
|
||||
resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net'))
|
||||
assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.text
|
||||
assert '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
|
||||
assert 'Foobar' in resp.text
|
||||
# check slugs
|
||||
assert 'id="unique"' in resp.text
|
||||
assert 'id="dup"' not in resp.text
|
||||
|
||||
# check {% now %} inside a skeleton_extra_placeholder is not interpreted
|
||||
assert '{% now ' in resp.text
|
||||
|
|
Loading…
Reference in New Issue