Print also applications without a number.

This commit is contained in:
Emanuel Schuetze 2011-09-07 20:37:56 +02:00
parent fa71a1236d
commit 123426329d

View File

@ -335,10 +335,11 @@ def print_passwords(request):
def get_application(application, story): def get_application(application, story):
# application number # application number
if application.number is None: if application.number:
story.append(Paragraph(_("Application No."), stylesheet['Heading1']))
else:
story.append(Paragraph(_("Application No.")+" %s" % application.number, stylesheet['Heading1'])) story.append(Paragraph(_("Application No.")+" %s" % application.number, stylesheet['Heading1']))
else:
story.append(Paragraph(_("Application No."), stylesheet['Heading1']))
# submitter # submitter
cell1a = [] cell1a = []
@ -380,7 +381,14 @@ def get_application(application, story):
else: else:
cell3b.append(Paragraph("%s" % application.get_status_display(), stylesheet['Normal'])) cell3b.append(Paragraph("%s" % application.get_status_display(), stylesheet['Normal']))
# table
data = []
data.append([cell1a,cell1b])
data.append([cell2a,cell2b])
data.append([cell3a,cell3b])
# voting results # voting results
if len(application.results) > 0:
cell4a = [] cell4a = []
cell4a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Vote results"), stylesheet['Heading4'])) cell4a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Vote results"), stylesheet['Heading4']))
cell4b = [] cell4b = []
@ -391,12 +399,8 @@ def get_application(application, story):
cell4b.append(Paragraph("%s. %s" % (ballotcounter, _("Vote")), stylesheet['Bold'])) cell4b.append(Paragraph("%s. %s" % (ballotcounter, _("Vote")), stylesheet['Bold']))
cell4b.append(Paragraph("%s: %s <br/> %s: %s <br/> %s: %s <br/> %s: %s <br/> %s: %s" % (_("Yes"), result[0], _("No"), result[1], _("Abstention"), result[2], _("Invalid"), result[3], _("Votes cast"), result[4]), stylesheet['Normal'])) cell4b.append(Paragraph("%s: %s <br/> %s: %s <br/> %s: %s <br/> %s: %s <br/> %s: %s" % (_("Yes"), result[0], _("No"), result[1], _("Abstention"), result[2], _("Invalid"), result[3], _("Votes cast"), result[4]), stylesheet['Normal']))
cell4b.append(Spacer(0,0.2*cm)) cell4b.append(Spacer(0,0.2*cm))
# table
data = []
data.append([cell1a,cell1b])
data.append([cell2a,cell2b])
data.append([cell3a,cell3b])
data.append([cell4a,cell4b]) data.append([cell4a,cell4b])
t=Table(data) t=Table(data)
t._argW[0]=4.5*cm t._argW[0]=4.5*cm
t._argW[1]=11*cm t._argW[1]=11*cm
@ -429,15 +433,22 @@ def print_application(request, application_id=None):
story.append(Paragraph(_("Applications"), stylesheet['Heading1'])) story.append(Paragraph(_("Applications"), stylesheet['Heading1']))
story.append(Spacer(0,0.75*cm)) story.append(Spacer(0,0.75*cm))
# List of applications # List of applications
for application in Application.objects.exclude(number=None).order_by('number'): for application in Application.objects.order_by('number'):
if application.number:
story.append(Paragraph(_("Application No.")+" %s: %s" % (application.number, application.title), stylesheet['Heading3'])) story.append(Paragraph(_("Application No.")+" %s: %s" % (application.number, application.title), stylesheet['Heading3']))
else:
story.append(Paragraph(_("Application No.")+"&nbsp;&nbsp;&nbsp;: %s" % (application.title), stylesheet['Heading3']))
# Applications details (each application on single page) # Applications details (each application on single page)
for application in Application.objects.exclude(number=None).order_by('number'): for application in Application.objects.order_by('number'):
story.append(PageBreak()) story.append(PageBreak())
story = get_application(application, story) story = get_application(application, story)
else: # print selected application else: # print selected application
application = Application.objects.get(id=application_id) application = Application.objects.get(id=application_id)
filename = u'filename=%s%s.pdf;' % (_("Application"), str(application.number)) if application.number:
number = application.number
else:
number = ""
filename = u'filename=%s%s.pdf;' % (_("Application"), str(number))
response['Content-Disposition'] = filename.encode('utf-8') response['Content-Disposition'] = filename.encode('utf-8')
story = get_application(application, story) story = get_application(application, story)