mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +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)
|
||||
|
||||
buffer = rml2pdf.parseString(rml)
|
||||
merger.append(PdfFileReader(buffer))
|
||||
buffer.close()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{% load filters %}
|
||||
<setNextFrame name="main"/>
|
||||
<nextFrame/>
|
||||
|
||||
|
||||
<blockTable style="headLayout" colWidths="330,165">
|
||||
<tr>
|
||||
<td>
|
||||
@@ -13,7 +12,7 @@
|
||||
|
||||
<keepInFrame>
|
||||
<para style="style.event_description">
|
||||
{{ object.description|default_if_none:""|linebreaksbr }}
|
||||
{{ object.description|default_if_none:""|linebreaksxml }}
|
||||
</para>
|
||||
</keepInFrame>
|
||||
</td>
|
||||
@@ -75,9 +74,9 @@
|
||||
{% if invoice %}
|
||||
<keepInFrame>
|
||||
{% 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 %}
|
||||
<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 %}
|
||||
</keepInFrame>
|
||||
{% endif %}
|
||||
@@ -109,12 +108,12 @@
|
||||
<h3>{{ object.venue.name }}</h3>
|
||||
{% if not invoice %}
|
||||
<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>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td rightPadding="0">
|
||||
|
||||
|
||||
<h2>Timings</h2>
|
||||
<blockTable style="eventDetails" colWidths="55,75">
|
||||
<tr>
|
||||
@@ -185,7 +184,7 @@
|
||||
{% if item.description %}
|
||||
</para>
|
||||
<para style="item_description">
|
||||
<em>{{ item.description|linebreaksbr }}</em>
|
||||
<em>{{ item.description|linebreaksxml }}</em>
|
||||
</para>
|
||||
<para>
|
||||
{% endif %}
|
||||
|
||||
@@ -2,10 +2,24 @@ from django import template
|
||||
from django import forms
|
||||
from django.forms.forms import NON_FIELD_ERRORS
|
||||
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.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
|
||||
def multiply(value, arg):
|
||||
return value * arg
|
||||
|
||||
Reference in New Issue
Block a user