adapt to template changes (#25057)

This commit is contained in:
Frédéric Péters 2018-07-04 20:38:42 +02:00
parent 5f2a981341
commit 29a82c1d19
1 changed files with 15 additions and 3 deletions

View File

@ -8,15 +8,26 @@ from wcs.qommon.admin.texts import TextsDirectory
from wcs.categories import Category
wcs_error_page = template.error_page
wcs_get_decorate_vars = template.get_decorate_vars
def render_response(publisher, body):
response = publisher.get_request().response
body = str(body)
def get_decorate_vars(body, response, generate_breadcrumb=True, template_context=None, **kwargs):
if template_context and 'form_side' in template_context:
# force rendering as it will put new variables in the context
template_context['form_side'] = template_context['form_side']()
for key in ('bigdiv', 'gauche'):
if not response.filter.has_key(key):
response.filter[key] = None
return wcs_get_decorate_vars(body, response, generate_breadcrumb)
def render_response(publisher, body):
response = get_response()
if isinstance(body, template.QommonTemplateResponse):
body = template.render(body.templates, body.context)
root_url = publisher.get_root_url()
wcs_path = publisher.get_request().get_path()[len(root_url):]
section = wcs_path.split('/')[0]
@ -77,6 +88,7 @@ def error_page(*args, **kwargs):
return htmltext('<div id="info"><h2>%s</h2>' % title) + error_page + htmltext('</div>')
template.error_page = error_page
template.get_decorate_vars = get_decorate_vars
get_publisher_class().render_response = render_response
TextsDirectory.register('aq-error-assistance', N_('Assistance text next to errors'))