cleaned poll pdf for assignment and application

This commit is contained in:
Oskar Hahn 2012-06-29 00:19:06 +02:00
parent a00fe2b241
commit 6d3061f8af
6 changed files with 50 additions and 57 deletions

View File

@ -76,9 +76,9 @@ class ConfigForm(Form, CssClassMixin):
required=False,
label=_("Number of ballot papers (selection)"),
choices=[
("1", _("Number of all delegates")),
("2", _("Number of all participants")),
("0", _("Use the following custum number")),
("NUMBER_OF_DELEGATES", _("Number of all delegates")),
("NUMBER_OF_ALL_PARTICIPANTS", _("Number of all participants")),
("CUSTOM_NUMBER", _("Use the following custom number")),
]
)
application_pdf_ballot_papers_number = IntegerField(

View File

@ -574,9 +574,9 @@ from openslides.config.signals import default_config_value
def default_config(sender, key, **kwargs):
return {
'application_min_supporters': 0,
'application_preamble': 'Die Versammlung möge beschließen,',
'application_pdf_ballot_papers_selection': '1',
'application_pdf_ballot_papers_number': '1',
'application_preamble': _('The Assembly may decide,'),
'application_pdf_ballot_papers_selection': 'CUSTOM_NUMBER',
'application_pdf_ballot_papers_number': '8',
'application_pdf_title': _('Applications'),
'application_pdf_preamble': '',
}.get(key)

View File

@ -835,15 +835,16 @@ class ApplicationPollPDF(PDFView):
# get ballot papers config values
ballot_papers_selection = config["application_pdf_ballot_papers_selection"]
ballot_papers_number = config["application_pdf_ballot_papers_number"]
# set number of ballot papers
if ballot_papers_selection == "1":
if ballot_papers_selection == "NUMBER_OF_DELEGATES":
number = User.objects.filter(profile__type__iexact="delegate").count()
if ballot_papers_selection == "2":
number = int(User.objects.count() - 1)
if ballot_papers_selection == "0":
elif ballot_papers_selection == "NUMBER_OF_ALL_PARTICIPANTS":
number = int(Profile.objects.count())
else: # ballot_papers_selection == "CUSTOM_NUMBER"
number = int(ballot_papers_number)
if number == 0:
number = 1
number = max(1, number)
# print ballot papers
if number > 0:
for user in xrange(number/2):

View File

@ -43,9 +43,9 @@ class ConfigForm(Form, CssClassMixin):
required=False,
label=_("Number of ballot papers (selection)"),
choices=(
("1", _("Number of all delegates")),
("2", _("Number of all participants")),
("0", _("Use the following custum number"))
("NUMBER_OF_DELEGATES", _("Number of all delegates")),
("NUMBER_OF_ALL_PARTICIPANTS", _("Number of all participants")),
("CUSTOM_NUMBER", _("Use the following custom number"))
)
)
assignment_pdf_ballot_papers_number = forms.IntegerField(

View File

@ -235,8 +235,8 @@ from openslides.config.signals import default_config_value
def default_config(sender, key, **kwargs):
return {
'assignment_publish_winner_results_only': False,
'assignment_pdf_ballot_papers_selection': '1',
'assignment_pdf_ballot_papers_number': '1',
'assignment_pdf_ballot_papers_selection': 'CUSTOM_NUMBER',
'assignment_pdf_ballot_papers_number': '8',
'assignment_pdf_title': _('Elections'),
'assignment_pdf_preamble': '',
'assignment_poll_vote_values': 'auto',

View File

@ -513,68 +513,60 @@ class AssignmentPollPDF(PDFView):
data= []
# get ballot papers config values
number = 1
ballot_papers_selection = config["assignment_pdf_ballot_papers_selection"]
ballot_papers_number = config["assignment_pdf_ballot_papers_number"]
# set number of ballot papers
if ballot_papers_selection == "NUMBER_OF_DELEGATES":
number = User.objects.filter(profile__type__iexact="delegate").count()
elif ballot_papers_selection == "NUMBER_OF_ALL_PARTICIPANTS":
number = int(Profile.objects.count())
else: # ballot_papers_selection == "CUSTOM_NUMBER"
number = int(ballot_papers_number)
number = max(1, number)
# Choose kind of ballot paper
if self.poll.yesnoabstain:
for option in options:
o = str(option).split("(",1)
cell.append(Paragraph(o[0], stylesheet['Ballot_option_name']))
if len(o) > 1:
cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group']))
candidate = option.candidate
cell.append(Paragraph(candidate.user.get_full_name(), stylesheet['Ballot_option_name']))
if candidate.group:
cell.append(Paragraph("(%s)" % candidate.group, stylesheet['Ballot_option_group']))
else:
cell.append(Paragraph(" ", stylesheet['Ballot_option_group']))
cell.append(Paragraph(circle+_("Yes")+"      "+circle+_("No")+"      "+circle+_("Abstention"), stylesheet['Ballot_option_YNA']))
# set number of ballot papers
if ballot_papers_selection == "1":
number = User.objects.filter(profile__type__iexact="delegate").count()
if ballot_papers_selection == "2":
number = int(User.objects.count() - 1)
if ballot_papers_selection == "0":
number = int(ballot_papers_number)
# print ballot papers
for user in xrange(number/2):
data.append([cell,cell])
for user in xrange(number / 2):
data.append([cell, cell])
rest = number % 2
if rest:
data.append([cell,''])
data.append([cell, ''])
if len(options) <= 2:
t=Table(data, 10.5*cm, 7.42*cm)
t = Table(data, 10.5*cm, 7.42*cm)
elif len(options) <= 5:
t=Table(data, 10.5*cm, 14.84*cm)
t = Table(data, 10.5*cm, 14.84*cm)
else:
t=Table(data, 10.5*cm, 29.7*cm)
t = Table(data, 10.5*cm, 29.7*cm)
else:
for option in options:
o = str(option).split("(",1)
cell.append(Paragraph(circle+o[0], stylesheet['Ballot_option_name']))
if len(o) > 1:
cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group_right']))
candidate = option.candidate
cell.append(Paragraph(circle + candidate.user.get_full_name(), stylesheet['Ballot_option_name']))
if candidate.group:
cell.append(Paragraph("(%s)" % candidate.group, stylesheet['Ballot_option_group_right']))
else:
cell.append(Paragraph("&nbsp;", stylesheet['Ballot_option_group_right']))
# set number of ballot papers
if ballot_papers_selection == "1":
number = User.objects.filter(profile__type__iexact="delegate").count()
if ballot_papers_selection == "2":
number = int(User.objects.count() - 1)
if ballot_papers_selection == "0":
number = int(ballot_papers_number)
if number == 0:
number = 1
# print ballot papers
if number > 0:
for user in xrange(number/2):
data.append([cell,cell])
for user in xrange(number / 2):
data.append([cell, cell])
rest = number % 2
if rest:
data.append([cell,''])
data.append([cell, ''])
if len(options) <= 4:
t=Table(data, 10.5*cm, 7.42*cm)
t = Table(data, 10.5*cm, 7.42*cm)
elif len(options) <= 8:
t=Table(data, 10.5*cm, 14.84*cm)
t = Table(data, 10.5*cm, 14.84*cm)
else:
t=Table(data, 10.5*cm, 29.7*cm)
t = Table(data, 10.5*cm, 29.7*cm)
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
('VALIGN', (0,0), (-1,-1), 'TOP'),