Turn on Yes-No-Abstain Ballot for Assignments/Elections, #108

This commit is contained in:
Norman Jäckel 2012-06-28 18:45:00 +02:00
parent 59fb053283
commit 3156c8b4b5

View File

@ -516,68 +516,66 @@ class AssignmentPollPDF(PDFView):
number = 1 number = 1
ballot_papers_selection = config["assignment_pdf_ballot_papers_selection"] ballot_papers_selection = config["assignment_pdf_ballot_papers_selection"]
ballot_papers_number = config["assignment_pdf_ballot_papers_number"] ballot_papers_number = config["assignment_pdf_ballot_papers_number"]
# TODO: 'optiondecision' # Choose kind of ballot paper
#if self.poll.optiondecision: if self.poll.yesnoababstain:
# for option in options: for option in options:
# o = str(option).split("(",1) o = str(option).split("(",1)
# cell.append(Paragraph(o[0], stylesheet['Ballot_option_name'])) cell.append(Paragraph(o[0], stylesheet['Ballot_option_name']))
# if len(o) > 1: if len(o) > 1:
# cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group'])) cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group']))
# else: else:
# cell.append(Paragraph(" ", stylesheet['Ballot_option_group'])) cell.append(Paragraph(" ", stylesheet['Ballot_option_group']))
# cell.append(Paragraph(circle+_("Yes")+"      "+circle+_("No")+"      "+circle+_("Abstention"), stylesheet['Ballot_option_YNA'])) cell.append(Paragraph(circle+_("Yes")+"      "+circle+_("No")+"      "+circle+_("Abstention"), stylesheet['Ballot_option_YNA']))
# # set number of ballot papers # set number of ballot papers
# if ballot_papers_selection == "1": if ballot_papers_selection == "1":
# number = User.objects.filter(profile__type__iexact="delegate").count() number = User.objects.filter(profile__type__iexact="delegate").count()
# if ballot_papers_selection == "2": if ballot_papers_selection == "2":
# number = int(User.objects.count() - 1) number = int(User.objects.count() - 1)
# if ballot_papers_selection == "0": if ballot_papers_selection == "0":
# number = int(ballot_papers_number) number = int(ballot_papers_number)
# # print ballot papers # print ballot papers
# for user in xrange(number/2):
# data.append([cell,cell])
# rest = number % 2
# if rest:
# data.append([cell,''])
# if len(options) <= 2:
# t=Table(data, 10.5*cm, 7.42*cm)
# elif len(options) <= 5:
# t=Table(data, 10.5*cm, 14.84*cm)
# else:
# 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']))
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): for user in xrange(number/2):
data.append([cell,cell]) data.append([cell,cell])
rest = number % 2 rest = number % 2
if rest: if rest:
data.append([cell,'']) data.append([cell,''])
if len(options) <= 2:
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) <= 5:
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)
else: else:
t=Table(data, 10.5*cm, 29.7*cm) 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']))
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])
rest = number % 2
if rest:
data.append([cell,''])
if len(options) <= 4:
t=Table(data, 10.5*cm, 7.42*cm)
elif len(options) <= 8:
t=Table(data, 10.5*cm, 14.84*cm)
else:
t=Table(data, 10.5*cm, 29.7*cm)
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey), t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
('VALIGN', (0,0), (-1,-1), 'TOP'), ('VALIGN', (0,0), (-1,-1), 'TOP'),
])) ]))