misc: don't create a fake template for 404 errors (#9110)
This commit is contained in:
parent
405b41020c
commit
3c560f30f9
|
@ -205,7 +205,7 @@ def page(request):
|
|||
|
||||
return publish_page(request, page)
|
||||
|
||||
def publish_page(request, page, status=200):
|
||||
def publish_page(request, page, status=200, template_name=None):
|
||||
pages = list(page.get_parents_and_self())
|
||||
|
||||
if not page.is_visible(request.user):
|
||||
|
@ -217,8 +217,6 @@ def publish_page(request, page, status=200):
|
|||
if page.redirect_url:
|
||||
return HttpResponseRedirect(page.redirect_url)
|
||||
|
||||
combo_template = settings.COMBO_PUBLIC_TEMPLATES[page.template_name]
|
||||
|
||||
cells = CellBase.get_cells(page_id=page.id)
|
||||
extend_with_locked_placeholders_cells(cells, page, pages)
|
||||
cells = [x for x in cells if x.is_visible(user=request.user)]
|
||||
|
@ -231,7 +229,10 @@ def publish_page(request, page, status=200):
|
|||
'media': sum((cell.media for cell in cells), Media())
|
||||
}
|
||||
|
||||
template_name = combo_template['template']
|
||||
if not template_name:
|
||||
combo_template = settings.COMBO_PUBLIC_TEMPLATES[page.template_name]
|
||||
template_name = combo_template['template']
|
||||
|
||||
return render(request, template_name, ctx, status=status)
|
||||
|
||||
def error404(request, *args, **kwargs):
|
||||
|
@ -241,8 +242,5 @@ def error404(request, *args, **kwargs):
|
|||
from django.views.defaults import page_not_found
|
||||
return page_not_found(request)
|
||||
page = Page()
|
||||
page.template_name = '404'
|
||||
if not '404' in settings.COMBO_PUBLIC_TEMPLATES:
|
||||
settings.COMBO_PUBLIC_TEMPLATES['404'] = settings.COMBO_PUBLIC_TEMPLATES['standard'].copy()
|
||||
settings.COMBO_PUBLIC_TEMPLATES['404']['template'] = 'combo/404.html'
|
||||
return publish_page(request, page, status=404)
|
||||
page.template_name = 'standard'
|
||||
return publish_page(request, page, status=404, template_name='combo/404.html')
|
||||
|
|
Loading…
Reference in New Issue