pages: always display placeholder blocks in skeleton (#26641)

This commit is contained in:
Lauréline Guérin 2019-10-21 17:15:50 +02:00
parent 7087aa3849
commit 0c854a9e50
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
4 changed files with 12 additions and 6 deletions

View File

@ -91,6 +91,12 @@
<div id="page-content">
{% if object.redirect_url %}
<div class="infonotice">
<p>{% blocktrans with redirect_url=object.redirect_url %}This page is configured as a redirection to the URL "{{ redirect_url }}", it can also be used as a template for the pages behind this URL.{% endblocktrans %}</p>
</div>
{% endif %}
<div id="placeholders"
data-cell-order-url="{% url 'combo-manager-cell-order' page_pk=object.id %}"
>

View File

@ -1,5 +1,8 @@
{% load combo i18n %}
{% if render %}
{% if render_skeleton %}
{{ skeleton }}
{% endif %}
{% for cell in cells %}
<div class="cell {{ cell.css_class_names }} {% if cell.slug %}{{cell.slug}}{% endif %} {% if cell|shown_because_admin:request %}shown-because-admin{% endif %}"
{% if cell.slug and cell.use_slug_as_id %}id="{{ cell.slug }}"{% endif %}
@ -9,7 +12,4 @@
{% if request.extra_context_data %}data-extra-context="{{ request.extra_context_data|signed|urlencode }}"{% endif %}
><div>{% render_cell cell %}</div></div>
{% endfor %}
{% if render_skeleton %}
{{ skeleton }}
{% endif %}
{% endif %}

View File

@ -67,7 +67,7 @@ def placeholder(context, placeholder_name, **options):
x.placeholder == placeholder_name and
(context.get('render_skeleton') or x.is_relevant(context) and
x.is_visible(context['request'].user))]
if context.get('render_skeleton') and not context['cells']:
if context.get('render_skeleton'):
context['skeleton'] = skeleton_text(context, placeholder_name)
else:
context['skeleton'] = ''

View File

@ -270,7 +270,7 @@ def test_page_skeleton(app):
cell.save()
resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net'))
assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.text
assert not '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
assert '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
assert 'Foobar' in resp.text
# check {% now %} inside a skeleton_extra_placeholder is not interpreted
@ -282,7 +282,7 @@ def test_page_skeleton(app):
page.save()
resp = app.get('/__skeleton__/?source=%s' % quote('http://127.0.0.1:8999/'))
assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.text
assert not '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
assert '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
assert 'Foobar' in resp.text
# check link cells provide a full URL