misc: fallback skeleton to standard page template (#46412) #106
|
@ -340,7 +340,10 @@ def skeleton(request):
|
|||
cells = [x for x in cells if x.is_visible(request, context={'render_skeleton': True})]
|
||||
|
||||
pages = selected_page.get_parents_and_self()
|
||||
combo_template = settings.COMBO_PUBLIC_TEMPLATES[selected_page.template_name]
|
||||
try:
|
||||
combo_template = settings.COMBO_PUBLIC_TEMPLATES[selected_page.template_name]
|
||||
except KeyError:
|
||||
combo_template = settings.COMBO_PUBLIC_TEMPLATES['standard']
|
||||
extend_with_parent_cells(cells, hierarchy=pages)
|
||||
mark_duplicated_slugs(cells)
|
||||
|
||||
|
@ -356,6 +359,11 @@ def skeleton(request):
|
|||
}
|
||||
|
||||
template_name = combo_template['template']
|
||||
try:
|
||||
get_template(template_name)
|
||||
except TemplateDoesNotExist:
|
||||
template_name = settings.COMBO_PUBLIC_TEMPLATES['standard'].get('template')
|
||||
|
||||
response = render(request, template_name, ctx)
|
||||
response.content = b'{%% with page_template_name="%s" %%}%s{%% endwith %%}' % (
|
||||
selected_page.template_name.encode(),
|
||||
|
|
|
@ -511,6 +511,32 @@ def test_page_skeleton(app):
|
|||
assert "Foobar2" in resp.text
|
||||
|
||||
|
||||
def test_page_skeleton_missing_template(app):
|
||||
Page.objects.all().delete()
|
||||
page = Page(
|
||||
title='Elsewhere', slug='elsewhere', template_name='missing', redirect_url='http://example.net/foo/'
|
||||
)
|
||||
page.save()
|
||||
|
||||
# template that is not even defined
|
||||
app.get('/__skeleton__/?source=%s' % quote('http://example.net/'), status=200)
|
||||
|
||||
# template with missing file
|
||||
with override_settings(
|
||||
COMBO_PUBLIC_TEMPLATES={
|
||||
'standard': {
|
||||
'name': 'Standard',
|
||||
'template': 'combo/page_template.html',
|
||||
},
|
||||
'missing': {
|
||||
'name': 'Missing',
|
||||
'template': 'combo/page_missing_template.html',
|
||||
},
|
||||
}
|
||||
):
|
||||
app.get('/__skeleton__/?source=%s' % quote('http://example.net/'), status=200)
|
||||
|
||||
|
||||
def test_subpage_location(app):
|
||||
Page.objects.all().delete()
|
||||
|
||||
|
|
Loading…
Reference in New Issue