Fixed motion pdf and template issues:
- Fixed #790 (Unicode Error while creating motion pdf if motion text contains umlauts and motion is imported from CSV) - Fixed #742: Added categories and identifier to motion pdf. - Fixed wrong title order (app title - OpenSlides).
This commit is contained in:
parent
c12a0efa21
commit
5dd65cb173
@ -23,7 +23,7 @@ from django.conf import settings
|
|||||||
|
|
||||||
from openslides.config.api import config
|
from openslides.config.api import config
|
||||||
from openslides.utils.pdf import stylesheet
|
from openslides.utils.pdf import stylesheet
|
||||||
from .models import Motion
|
from .models import Motion, Category
|
||||||
|
|
||||||
# Needed to count the delegates
|
# Needed to count the delegates
|
||||||
# TODO: find another way to do this.
|
# TODO: find another way to do this.
|
||||||
@ -45,7 +45,10 @@ def motion_to_pdf(pdf, motion):
|
|||||||
"""
|
"""
|
||||||
Create a PDF for one motion.
|
Create a PDF for one motion.
|
||||||
"""
|
"""
|
||||||
pdf.append(Paragraph(_("Motion: %s") % motion.title, stylesheet['Heading1']))
|
identifier = ""
|
||||||
|
if motion.identifier:
|
||||||
|
identifier = " %s" % motion.identifier
|
||||||
|
pdf.append(Paragraph(_("Motion") + "%s: %s" % (identifier, motion.title), stylesheet['Heading1']))
|
||||||
|
|
||||||
motion_data = []
|
motion_data = []
|
||||||
|
|
||||||
@ -204,7 +207,7 @@ def convert_html_to_reportlab(pdf, text):
|
|||||||
text = soup.body.contents
|
text = soup.body.contents
|
||||||
paragraph_number = 1
|
paragraph_number = 1
|
||||||
for paragraph in text:
|
for paragraph in text:
|
||||||
paragraph = str(paragraph)
|
paragraph = unicode(paragraph)
|
||||||
# ignore empty paragraphs (created by newlines/tabs of ckeditor)
|
# ignore empty paragraphs (created by newlines/tabs of ckeditor)
|
||||||
if paragraph == '\n' or paragraph == '\n\n' or paragraph == '\n\t':
|
if paragraph == '\n' or paragraph == '\n\n' or paragraph == '\n\t':
|
||||||
continue
|
continue
|
||||||
@ -222,7 +225,7 @@ def convert_html_to_reportlab(pdf, text):
|
|||||||
elif "<h3>" in paragraph:
|
elif "<h3>" in paragraph:
|
||||||
pdf.append(Paragraph(paragraph, stylesheet['InnerH3Paragraph']))
|
pdf.append(Paragraph(paragraph, stylesheet['InnerH3Paragraph']))
|
||||||
else:
|
else:
|
||||||
pdf.append(Paragraph(str(paragraph), stylesheet['InnerParagraph'], str(paragraph_number)))
|
pdf.append(Paragraph(paragraph, stylesheet['InnerParagraph'], str(paragraph_number)))
|
||||||
paragraph_number += 1
|
paragraph_number += 1
|
||||||
|
|
||||||
|
|
||||||
@ -238,11 +241,25 @@ def all_motion_cover(pdf, motions):
|
|||||||
|
|
||||||
pdf.append(Spacer(0, 0.75 * cm))
|
pdf.append(Spacer(0, 0.75 * cm))
|
||||||
|
|
||||||
|
# list of categories
|
||||||
|
categories = False
|
||||||
|
for i, category in enumerate(Category.objects.all()):
|
||||||
|
categories = True
|
||||||
|
if i == 0:
|
||||||
|
pdf.append(Paragraph(_("Categories"), stylesheet['Heading2']))
|
||||||
|
pdf.append(Paragraph("%s %s" % (category.prefix, category.name), stylesheet['Paragraph']))
|
||||||
|
if categories:
|
||||||
|
pdf.append(PageBreak())
|
||||||
|
|
||||||
|
# list of motions
|
||||||
if not motions:
|
if not motions:
|
||||||
pdf.append(Paragraph(_("No motions available."), stylesheet['Heading3']))
|
pdf.append(Paragraph(_("No motions available."), stylesheet['Heading3']))
|
||||||
else:
|
else:
|
||||||
for motion in motions:
|
for motion in motions:
|
||||||
pdf.append(Paragraph(motion.title, stylesheet['Heading3']))
|
identifier = ""
|
||||||
|
if motion.identifier:
|
||||||
|
identifier = "%s " % motion.identifier
|
||||||
|
pdf.append(Paragraph("%s%s" % (identifier, motion.title), stylesheet['Heading3']))
|
||||||
|
|
||||||
|
|
||||||
def motion_poll_to_pdf(pdf, poll):
|
def motion_poll_to_pdf(pdf, poll):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}{{ block.super }} – {% trans "Custom slide" %}{% endblock %}
|
{% block title %}{% trans "Custom slide" %} – {{ block.super }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{% trans 'Custom slide' %}
|
<h1>{% trans 'Custom slide' %}
|
||||||
|
Loading…
Reference in New Issue
Block a user