0002-pages-add-navigation-buttons-on-page-view-12437.patch
combo/manager/static/css/combo.manager.css | ||
---|---|---|
132 | 132 |
margin-left: 2em; |
133 | 133 |
} |
134 | 134 | |
135 |
.icon-eye-open:before { content: "\f06e "; } |
|
136 | ||
137 | 135 |
div.objects-list { |
138 | 136 |
clear: both; |
139 | 137 |
} |
... | ... | |
195 | 193 |
.icon-eye-open:before { content: "\f06e "; } |
196 | 194 |
.icon-edit:before { content: "\f044"; } |
197 | 195 | |
196 |
div.navigation ul, |
|
197 |
div.navigation li { |
|
198 |
margin: 0; |
|
199 |
padding: 0; |
|
200 |
list-style: none; |
|
201 |
line-height: 150%; |
|
202 |
} |
|
203 | ||
204 |
div.navigation li::before { |
|
205 |
content: ""; |
|
206 |
font-family: FontAwesome; |
|
207 |
display: inline-block; |
|
208 |
width: 2em; |
|
209 |
text-align: center; |
|
210 |
} |
|
211 | ||
212 |
div.navigation li.nav-left::before { |
|
213 |
content: "\f053"; /* chevron-left */ |
|
214 |
} |
|
215 | ||
216 |
div.navigation li.nav-right::before { |
|
217 |
content: "\f054"; /* chevron-right */ |
|
218 |
} |
|
219 | ||
220 |
div.navigation li.nav-up::before { |
|
221 |
content: "\f077"; /* chevron-up */ |
|
222 |
} |
|
223 | ||
198 | 224 |
#assets-browser { |
199 | 225 |
display: flex; |
200 | 226 |
} |
combo/manager/templates/combo/page_view.html | ||
---|---|---|
84 | 84 | |
85 | 85 |
</div> |
86 | 86 | |
87 |
{% if object.parent_id or previous_page or next_page %} |
|
88 |
<div class="page-options navigation"> |
|
89 |
<h3>{% trans 'Navigation' %}</h3> |
|
90 |
<ul> |
|
91 |
{% if object.parent_id %} |
|
92 |
<li class="nav-up"><a href="{% url 'combo-manager-page-view' pk=object.parent_id %}">{{ object.parent.title }}</a></li> |
|
93 |
{% endif %} |
|
94 |
{% if previous_page %} |
|
95 |
<li class="nav-left"><a href="{% url 'combo-manager-page-view' pk=previous_page.pk %}">{{ previous_page.title }}</a></li> |
|
96 |
{% endif %} |
|
97 |
{% if next_page %} |
|
98 |
<li class="nav-right"><a href="{% url 'combo-manager-page-view' pk=next_page.pk %}">{{ next_page.title }}</a></li> |
|
99 |
{% endif %} |
|
100 |
</ul> |
|
101 |
</div> |
|
102 |
{% endif %} |
|
103 | ||
87 | 104 |
</aside> |
88 | 105 |
{% endblock %} {# sidebar #} |
89 | 106 |
combo/manager/views.py | ||
---|---|---|
255 | 255 |
placeholders.append(placeholder_dict) |
256 | 256 | |
257 | 257 |
context['placeholders'] = placeholders |
258 | ||
259 |
context.update({ |
|
260 |
'previous_page': self.object.get_previous_page(check_visibility=False), |
|
261 |
'next_page': self.object.get_next_page(check_visibility=False), |
|
262 |
}) |
|
263 | ||
258 | 264 |
return context |
259 | 265 | |
266 | ||
260 | 267 |
page_view = requires_csrf_token(PageView.as_view()) |
261 | 268 | |
262 | 269 |
tests/test_manager.py | ||
---|---|---|
208 | 208 |
assert 'foobar' in resp.text |
209 | 209 | |
210 | 210 | |
211 |
def test_edit_page_navigation(app, admin_user): |
|
212 |
page1 = Page.objects.create(title='One', slug='one', parent=None, template_name='standard') |
|
213 |
page2 = Page.objects.create(title='Two', slug='two', parent=page1, template_name='standard') |
|
214 |
page3 = Page.objects.create(title='Three', slug='three', parent=page1, template_name='standard') |
|
215 |
page4 = Page.objects.create(title='Four', slug='four', parent=None, template_name='standard') |
|
216 | ||
217 |
app = login(app) |
|
218 | ||
219 |
resp = app.get('/manage/pages/%s/' % page1.pk) |
|
220 |
assert '<li class="nav-up"' not in resp.text |
|
221 |
assert '<li class="nav-left"' not in resp.text |
|
222 |
assert '<li class="nav-right"><a href="/manage/pages/%s/">%s</a></li>' % (page2.pk, page2.title) in resp.text |
|
223 | ||
224 |
resp = app.get('/manage/pages/%s/' % page2.pk) |
|
225 |
assert '<li class="nav-up"><a href="/manage/pages/%s/">%s</a></li>' % (page1.pk, page1.title) in resp.text |
|
226 |
assert '<li class="nav-left"><a href="/manage/pages/%s/">%s</a></li>' % (page1.pk, page1.title) in resp.text |
|
227 |
assert '<li class="nav-right"><a href="/manage/pages/%s/">%s</a></li>' % (page3.pk, page3.title) in resp.text |
|
228 | ||
229 |
resp = app.get('/manage/pages/%s/' % page4.pk) |
|
230 |
assert '<li class="nav-up"' not in resp.text |
|
231 |
assert '<li class="nav-left"><a href="/manage/pages/%s/">%s</a></li>' % (page3.pk, page3.title) in resp.text |
|
232 |
assert '<li class="nav-right"' not in resp.text |
|
233 | ||
234 | ||
211 | 235 |
def test_delete_page(app, admin_user): |
212 | 236 |
Page.objects.all().delete() |
213 | 237 |
page = Page(title='One', slug='one', template_name='standard') |
... | ... | |
1027 | 1051 |
assert resp.headers['content-type'] == 'application/javascript' |
1028 | 1052 |
assert resp.text.startswith('fooBar([{"') |
1029 | 1053 | |
1054 | ||
1030 | 1055 |
def test_page_multiple_link_cells(app, admin_user): |
1031 | 1056 |
Page.objects.all().delete() |
1032 | 1057 |
page = Page(title='One', slug='one', template_name='standard') |
... | ... | |
1039 | 1064 |
patched_orig = Page.get_as_reordered_flat_hierarchy |
1040 | 1065 |
app = login(app) |
1041 | 1066 |
with mock.patch('combo.data.models.Page.get_as_reordered_flat_hierarchy') as func: |
1042 |
func.return_value = [] |
|
1043 |
resp = app.get('/manage/pages/%s/' % page.id) |
|
1044 |
assert func.call_count == 1 |
|
1067 |
func.side_effect = lambda *args, **kwargs: patched_orig(*args, **kwargs) |
|
1068 |
app.get('/manage/pages/%s/' % page.id) |
|
1069 |
# only 1 call for combo.data.forms.get_page_choices |
|
1070 |
# 1 call for get_previous_page and 1 call for get_next_page |
|
1071 |
assert func.call_count == 3 |
|
1072 | ||
1045 | 1073 | |
1046 | 1074 |
def test_page_cell_placeholder(app, admin_user): |
1047 | 1075 |
page = Page(title='One', slug='one', template_name='standard') |
1048 |
- |