mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-27 10:22:17 +00:00
FIX: Fix broken newlining in PDFs
Introduced by a change in Django 2.1 'HTML rendered by form widgets no longer includes a closing slash on void elements, e.g. <br>. This is incompatible within XHTML, although some widgets already used aspects of HTML5 such as boolean attributes.'
This commit is contained in:
@@ -206,7 +206,6 @@ class EventPrint(generic.View):
|
|||||||
}
|
}
|
||||||
|
|
||||||
rml = template.render(context)
|
rml = template.render(context)
|
||||||
|
|
||||||
buffer = rml2pdf.parseString(rml)
|
buffer = rml2pdf.parseString(rml)
|
||||||
merger.append(PdfFileReader(buffer))
|
merger.append(PdfFileReader(buffer))
|
||||||
buffer.close()
|
buffer.close()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
{% load filters %}
|
||||||
<setNextFrame name="main"/>
|
<setNextFrame name="main"/>
|
||||||
<nextFrame/>
|
<nextFrame/>
|
||||||
|
|
||||||
|
|
||||||
<blockTable style="headLayout" colWidths="330,165">
|
<blockTable style="headLayout" colWidths="330,165">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@@ -13,7 +12,7 @@
|
|||||||
|
|
||||||
<keepInFrame>
|
<keepInFrame>
|
||||||
<para style="style.event_description">
|
<para style="style.event_description">
|
||||||
{{ object.description|default_if_none:""|linebreaksbr }}
|
{{ object.description|default_if_none:""|linebreaksxml }}
|
||||||
</para>
|
</para>
|
||||||
</keepInFrame>
|
</keepInFrame>
|
||||||
</td>
|
</td>
|
||||||
@@ -75,9 +74,9 @@
|
|||||||
{% if invoice %}
|
{% if invoice %}
|
||||||
<keepInFrame>
|
<keepInFrame>
|
||||||
{% if object.organisation.address %}
|
{% if object.organisation.address %}
|
||||||
<para style="specific_description">{{ object.organisation.address|default_if_none:""|linebreaksbr }}</para>
|
<para style="specific_description">{{ object.organisation.address|default_if_none:""|linebreaksxml }}</para>
|
||||||
{% elif object.person.address %}
|
{% elif object.person.address %}
|
||||||
<para style="specific_description">{{ object.person.address|default_if_none:""|linebreaksbr }}</para>
|
<para style="specific_description">{{ object.person.address|default_if_none:""|linebreaksxml }}</para>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</keepInFrame>
|
</keepInFrame>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -109,7 +108,7 @@
|
|||||||
<h3>{{ object.venue.name }}</h3>
|
<h3>{{ object.venue.name }}</h3>
|
||||||
{% if not invoice %}
|
{% if not invoice %}
|
||||||
<keepInFrame>
|
<keepInFrame>
|
||||||
<para style="specific_description">{{ object.venue.address|default_if_none:""|linebreaksbr }}</para>
|
<para style="specific_description">{{ object.venue.address|default_if_none:""|linebreaksxml }}</para>
|
||||||
</keepInFrame>
|
</keepInFrame>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
@@ -185,7 +184,7 @@
|
|||||||
{% if item.description %}
|
{% if item.description %}
|
||||||
</para>
|
</para>
|
||||||
<para style="item_description">
|
<para style="item_description">
|
||||||
<em>{{ item.description|linebreaksbr }}</em>
|
<em>{{ item.description|linebreaksxml }}</em>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -2,10 +2,24 @@ from django import template
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.forms.forms import NON_FIELD_ERRORS
|
from django.forms.forms import NON_FIELD_ERRORS
|
||||||
from django.forms.utils import ErrorDict
|
from django.forms.utils import ErrorDict
|
||||||
|
from django.utils.text import normalize_newlines
|
||||||
|
from django.template.defaultfilters import stringfilter
|
||||||
|
from django.utils.safestring import SafeData, mark_safe
|
||||||
|
from django.utils.html import escape
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(is_safe=True, needs_autoescape=True)
|
||||||
|
@stringfilter
|
||||||
|
def linebreaksxml(value, autoescape=True):
|
||||||
|
autoescape = autoescape and not isinstance(value, SafeData)
|
||||||
|
value = normalize_newlines(value)
|
||||||
|
if autoescape:
|
||||||
|
value = escape(value)
|
||||||
|
return mark_safe(value.replace('\n', '<br />'))
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def multiply(value, arg):
|
def multiply(value, arg):
|
||||||
return value * arg
|
return value * arg
|
||||||
|
|||||||
Reference in New Issue
Block a user