Fixed #1326 (Rearanged assignment pdf table cells to prevent a LayoutError)
This commit is contained in:
parent
b9842ecf94
commit
6df6b92dd7
@ -15,8 +15,7 @@ Motions:
|
||||
- Fixed motion detail view template. Added block to enable extra content via
|
||||
plugins.
|
||||
Assignments:
|
||||
- Fixed PDF when an assignment has a lot of posts. Used only 7 signature
|
||||
lines.
|
||||
- Fixed PDF build error when an election has more than 20 posts or candidates.
|
||||
Participants:
|
||||
- Fixed participant csv import with group ids:
|
||||
* Allowed to add multiple groups in csv group id field, e. g. "3,4".
|
||||
|
@ -8,7 +8,7 @@ from django.utils.translation import ungettext
|
||||
from reportlab.lib import colors
|
||||
from reportlab.lib.units import cm
|
||||
from reportlab.platypus import (PageBreak, Paragraph, SimpleDocTemplate, Spacer,
|
||||
Table, TableStyle)
|
||||
LongTable, Table, TableStyle)
|
||||
|
||||
from openslides.agenda.views import CreateRelatedAgendaItemView as _CreateRelatedAgendaItemView
|
||||
from openslides.config.api import config
|
||||
@ -346,67 +346,62 @@ class AssignmentPDF(PDFView):
|
||||
story.append(Paragraph(
|
||||
_("Election: %s") % assignment.name, stylesheet['Heading1']))
|
||||
story.append(Spacer(0, 0.5 * cm))
|
||||
# posts
|
||||
cell1a = []
|
||||
cell1a.append(Paragraph(
|
||||
"<font name='Ubuntu-Bold'>%s:</font>" %
|
||||
_("Number of available posts"), stylesheet['Bold']))
|
||||
cell1b = []
|
||||
cell1b.append(Paragraph(str(assignment.posts), stylesheet['Paragraph']))
|
||||
# candidates
|
||||
cell2a = []
|
||||
cell2a.append(Paragraph(
|
||||
"<font name='Ubuntu-Bold'>%s:</font><seqreset"
|
||||
" id='counter'>" % _("Candidates"), stylesheet['Heading4']))
|
||||
cell2b = []
|
||||
|
||||
# Filling table rows...
|
||||
data = []
|
||||
polls = assignment.poll_set.filter(published=True)
|
||||
# 1. posts
|
||||
data.append([
|
||||
Paragraph("%s:" %
|
||||
_("Number of available posts"), stylesheet['Bold']),
|
||||
Paragraph(str(assignment.posts), stylesheet['Paragraph'])])
|
||||
|
||||
# 2a. if no polls available print candidates
|
||||
if not polls:
|
||||
data.append([
|
||||
Paragraph("%s:<seqreset id='counter'>" %
|
||||
_("Candidates"), stylesheet['Heading4']),
|
||||
[]])
|
||||
for candidate in assignment.candidates:
|
||||
cell2b.append(Paragraph(
|
||||
"<seq id='counter'/>. %s" % candidate,
|
||||
stylesheet['Signaturefield']))
|
||||
data.append([
|
||||
[],
|
||||
Paragraph("<seq id='counter'/>. %s" % candidate,
|
||||
stylesheet['Signaturefield'])])
|
||||
if assignment.status == "sea":
|
||||
for x in range(0, 7):
|
||||
cell2b.append(
|
||||
Paragraph(
|
||||
"<seq id='counter'/>. "
|
||||
data.append([
|
||||
[],
|
||||
Paragraph("<seq id='counter'/>. "
|
||||
"__________________________________________",
|
||||
stylesheet['Signaturefield']))
|
||||
cell2b.append(Spacer(0, 0.2 * cm))
|
||||
|
||||
# Election result
|
||||
stylesheet['Signaturefield'])])
|
||||
|
||||
# 2b. if polls available print election result
|
||||
if polls:
|
||||
# Preparing
|
||||
vote_results = assignment.vote_results(only_published=True)
|
||||
polls = assignment.poll_set.filter(published=True)
|
||||
data_votes = []
|
||||
|
||||
# Left side
|
||||
cell3a = []
|
||||
cell3a.append(Paragraph(
|
||||
cell = []
|
||||
cell.append(Paragraph(
|
||||
"%s:" % (_("Election result")), stylesheet['Heading4']))
|
||||
|
||||
if polls.count() == 1:
|
||||
cell3a.append(Paragraph(
|
||||
"%s %s" % (polls.count(), _("ballot")), stylesheet['Normal']))
|
||||
elif polls.count() > 1:
|
||||
cell3a.append(Paragraph(
|
||||
"%s %s" % (polls.count(), _("ballots")), stylesheet['Normal']))
|
||||
|
||||
# Add table head row
|
||||
headrow = []
|
||||
headrow.append(_("Candidates"))
|
||||
for poll in polls:
|
||||
headrow.append("%s." % poll.get_ballot())
|
||||
headrow.append("%s. %s" % (poll.get_ballot(), _("ballot")))
|
||||
data_votes.append(headrow)
|
||||
|
||||
# Add result rows
|
||||
elected_candidates = list(assignment.elected)
|
||||
length = len(vote_results)
|
||||
for candidate, poll_list in vote_results.iteritems():
|
||||
row = []
|
||||
|
||||
candidate_string = candidate.clean_name
|
||||
if candidate in elected_candidates:
|
||||
candidate_string = "* " + candidate_string
|
||||
if candidate.name_suffix:
|
||||
if candidate.name_suffix and length < 20:
|
||||
candidate_string += "\n(%s)" % candidate.name_suffix
|
||||
row.append(candidate_string)
|
||||
for vote in poll_list:
|
||||
@ -467,17 +462,13 @@ class AssignmentPDF(PDFView):
|
||||
('ROWBACKGROUNDS', (0, 1), (-1, -1), (colors.white, (.9, .9, .9)))
|
||||
])
|
||||
)
|
||||
|
||||
# table
|
||||
data = []
|
||||
data.append([cell1a, cell1b])
|
||||
if polls:
|
||||
data.append([cell3a, table_votes])
|
||||
data.append([cell, table_votes])
|
||||
if elected_candidates:
|
||||
data.append(['', '* = ' + _('elected')])
|
||||
else:
|
||||
data.append([cell2a, cell2b])
|
||||
data.append([Spacer(0, 0.2 * cm), ''])
|
||||
t = Table(data)
|
||||
|
||||
# table style
|
||||
data.append(['', ''])
|
||||
t = LongTable(data)
|
||||
t._argW[0] = 4.5 * cm
|
||||
t._argW[1] = 11 * cm
|
||||
t.setStyle(TableStyle([
|
||||
@ -486,7 +477,7 @@ class AssignmentPDF(PDFView):
|
||||
story.append(t)
|
||||
story.append(Spacer(0, 1 * cm))
|
||||
|
||||
# text
|
||||
# election description
|
||||
story.append(
|
||||
Paragraph("%s" % assignment.description.replace('\r\n', '<br/>'),
|
||||
stylesheet['Paragraph']))
|
||||
|
Loading…
Reference in New Issue
Block a user