pages: add navigation buttons on page view (#12437)
This commit is contained in:
parent
45309fd524
commit
09507f8988
|
@ -144,8 +144,6 @@ div.cell-list .empty-cell {
|
|||
margin-left: 2em;
|
||||
}
|
||||
|
||||
.icon-eye-open:before { content: "\f06e "; }
|
||||
|
||||
div.objects-list {
|
||||
clear: both;
|
||||
}
|
||||
|
@ -207,6 +205,34 @@ p#redirection {
|
|||
.icon-eye-open:before { content: "\f06e "; }
|
||||
.icon-edit:before { content: "\f044"; }
|
||||
|
||||
div.navigation ul,
|
||||
div.navigation li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
div.navigation li::before {
|
||||
content: "";
|
||||
font-family: FontAwesome;
|
||||
display: inline-block;
|
||||
width: 2em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.navigation li.nav-left::before {
|
||||
content: "\f053"; /* chevron-left */
|
||||
}
|
||||
|
||||
div.navigation li.nav-right::before {
|
||||
content: "\f054"; /* chevron-right */
|
||||
}
|
||||
|
||||
div.navigation li.nav-up::before {
|
||||
content: "\f077"; /* chevron-up */
|
||||
}
|
||||
|
||||
#assets-browser {
|
||||
display: flex;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,23 @@
|
|||
|
||||
</div>
|
||||
|
||||
{% if object.parent_id or previous_page or next_page %}
|
||||
<div class="page-options navigation">
|
||||
<h3>{% trans 'Navigation' %}</h3>
|
||||
<ul>
|
||||
{% if object.parent_id %}
|
||||
<li class="nav-up"><a href="{% url 'combo-manager-page-view' pk=object.parent_id %}">{{ object.parent.title }}</a></li>
|
||||
{% endif %}
|
||||
{% if previous_page %}
|
||||
<li class="nav-left"><a href="{% url 'combo-manager-page-view' pk=previous_page.pk %}">{{ previous_page.title }}</a></li>
|
||||
{% endif %}
|
||||
{% if next_page %}
|
||||
<li class="nav-right"><a href="{% url 'combo-manager-page-view' pk=next_page.pk %}">{{ next_page.title }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</aside>
|
||||
{% endblock %} {# sidebar #}
|
||||
|
||||
|
|
|
@ -276,8 +276,15 @@ class PageView(DetailView):
|
|||
placeholders.append(placeholder_dict)
|
||||
|
||||
context['placeholders'] = placeholders
|
||||
|
||||
context.update({
|
||||
'previous_page': self.object.get_previous_page(check_visibility=False),
|
||||
'next_page': self.object.get_next_page(check_visibility=False),
|
||||
})
|
||||
|
||||
return context
|
||||
|
||||
|
||||
page_view = requires_csrf_token(PageView.as_view())
|
||||
|
||||
|
||||
|
|
|
@ -226,6 +226,30 @@ def test_page_placeholder_restricted_visibility(app, admin_user):
|
|||
assert 'foobar' in resp.text
|
||||
|
||||
|
||||
def test_edit_page_navigation(app, admin_user):
|
||||
page1 = Page.objects.create(title='One', slug='one', parent=None, template_name='standard')
|
||||
page2 = Page.objects.create(title='Two', slug='two', parent=page1, template_name='standard')
|
||||
page3 = Page.objects.create(title='Three', slug='three', parent=page1, template_name='standard')
|
||||
page4 = Page.objects.create(title='Four', slug='four', parent=None, template_name='standard')
|
||||
|
||||
app = login(app)
|
||||
|
||||
resp = app.get('/manage/pages/%s/' % page1.pk)
|
||||
assert '<li class="nav-up"' not in resp.text
|
||||
assert '<li class="nav-left"' not in resp.text
|
||||
assert '<li class="nav-right"><a href="/manage/pages/%s/">%s</a></li>' % (page2.pk, page2.title) in resp.text
|
||||
|
||||
resp = app.get('/manage/pages/%s/' % page2.pk)
|
||||
assert '<li class="nav-up"><a href="/manage/pages/%s/">%s</a></li>' % (page1.pk, page1.title) in resp.text
|
||||
assert '<li class="nav-left"><a href="/manage/pages/%s/">%s</a></li>' % (page1.pk, page1.title) in resp.text
|
||||
assert '<li class="nav-right"><a href="/manage/pages/%s/">%s</a></li>' % (page3.pk, page3.title) in resp.text
|
||||
|
||||
resp = app.get('/manage/pages/%s/' % page4.pk)
|
||||
assert '<li class="nav-up"' not in resp.text
|
||||
assert '<li class="nav-left"><a href="/manage/pages/%s/">%s</a></li>' % (page3.pk, page3.title) in resp.text
|
||||
assert '<li class="nav-right"' not in resp.text
|
||||
|
||||
|
||||
def test_delete_page(app, admin_user):
|
||||
Page.objects.all().delete()
|
||||
page = Page(title='One', slug='one', template_name='standard')
|
||||
|
@ -1098,6 +1122,7 @@ def test_menu_json(app, admin_user):
|
|||
assert resp.headers['content-type'] == 'application/javascript'
|
||||
assert resp.text.startswith('fooBar([{"')
|
||||
|
||||
|
||||
def test_page_multiple_link_cells(app, admin_user):
|
||||
Page.objects.all().delete()
|
||||
page = Page(title='One', slug='one', template_name='standard')
|
||||
|
@ -1110,9 +1135,12 @@ def test_page_multiple_link_cells(app, admin_user):
|
|||
patched_orig = Page.get_as_reordered_flat_hierarchy
|
||||
app = login(app)
|
||||
with mock.patch('combo.data.models.Page.get_as_reordered_flat_hierarchy') as func:
|
||||
func.return_value = []
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
assert func.call_count == 1
|
||||
func.side_effect = lambda *args, **kwargs: patched_orig(*args, **kwargs)
|
||||
app.get('/manage/pages/%s/' % page.id)
|
||||
# only 1 call for combo.data.forms.get_page_choices
|
||||
# 1 call for get_previous_page and 1 call for get_next_page
|
||||
assert func.call_count == 3
|
||||
|
||||
|
||||
def test_page_cell_placeholder(app, admin_user):
|
||||
page = Page(title='One', slug='one', template_name='standard')
|
||||
|
|
Loading…
Reference in New Issue