update application pdf

This commit is contained in:
Oskar Hahn 2012-09-13 21:33:57 +02:00
parent 0cf0e58af9
commit d8136045bb
2 changed files with 55 additions and 56 deletions

View File

@ -136,11 +136,11 @@ class Application(models.Model, SlideMixin):
""" """
note = [] note = []
if self.status == "pub" and not self.enough_supporters: if self.status == "pub" and not self.enough_supporters:
note.append(_("Searching for supporters.")) note.append(ugettext("Searching for supporters."))
if self.status == "pub" and self.permitted is None: if self.status == "pub" and self.permitted is None:
note.append(_("Not yet authorized.")) note.append(ugettext("Not yet authorized."))
elif self.unpermitted_changes and self.permitted: elif self.unpermitted_changes and self.permitted:
note.append(_("Not yet authorized changes.")) note.append(ugettext("Not yet authorized changes."))
return note return note
@property @property

View File

@ -700,6 +700,9 @@ class ApplicationPDF(PDFView):
story = self.get_application(application, story) story = self.get_application(application, story)
def get_application(self, application, story): def get_application(self, application, story):
# Preparing Table
data = []
# application number # application number
if application.number: if application.number:
story.append(Paragraph(_("Motion No.")+" %s" % application.number, stylesheet['Heading1'])) story.append(Paragraph(_("Motion No.")+" %s" % application.number, stylesheet['Heading1']))
@ -708,85 +711,81 @@ class ApplicationPDF(PDFView):
# submitter # submitter
cell1a = [] cell1a = []
cell1a.append(Spacer(0,0.2*cm)) cell1a.append(Spacer(0, 0.2 * cm))
cell1a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Submitter"), stylesheet['Heading4'])) cell1a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Submitter"), stylesheet['Heading4']))
cell1b = [] cell1b = []
cell1b.append(Spacer(0,0.2*cm)) cell1b.append(Spacer(0, 0.2 * cm))
if application.status == "pub": cell1b.append(Paragraph("%s" % application.submitter, stylesheet['Normal']))
cell1b.append(Paragraph("__________________________________________",stylesheet['Signaturefield'])) data.append([cell1a, cell1b])
cell1b.append(Spacer(0,0.1*cm))
cell1b.append(Paragraph(_("Signature: %s") % application.submitter, stylesheet['Small']))
cell1b.append(Spacer(0,0.2*cm))
else:
cell1b.append(Paragraph(unicode(application.submitter), stylesheet['Normal']))
# supporters if application.status == "pub":
# Cell for the signature
cell2a = [] cell2a = []
cell2b = [] cell2b = []
if config['application_min_supporters']: cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Signature"), stylesheet['Heading4']))
cell2b.append(Paragraph("__________________________________________", stylesheet['Signaturefield']))
cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" % _("Supporters"), stylesheet['Heading4'])) cell2b.append(Spacer(0, 0.1 * cm))
for supporter in application.supporters:
cell2b.append(Paragraph("<seq id='counter'/>.&nbsp; %s" % unicode(supporter), stylesheet['Signaturefield']))
if application.status == "pub":
for x in range(0,application.missing_supporters):
cell2b.append(Paragraph("<seq id='counter'/>.&nbsp; __________________________________________",stylesheet['Signaturefield']))
cell2b.append(Spacer(0,0.2*cm)) cell2b.append(Spacer(0,0.2*cm))
data.append([cell2a, cell2b])
# supporters
if config['application_min_supporters']:
cell3a = []
cell3b = []
cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" % _("Supporters"), stylesheet['Heading4']))
for supporter in application.supporters:
cell3b.append(Paragraph("<seq id='counter'/>.&nbsp; %s" % supporter, stylesheet['Signaturefield']))
if application.status == "pub":
for x in range(application.missing_supporters):
cell3b.append(Paragraph("<seq id='counter'/>.&nbsp; __________________________________________",stylesheet['Signaturefield']))
cell3b.append(Spacer(0, 0.2 * cm))
data.append([cell3a, cell3b])
# status # status
note = "" cell4a = []
for n in application.notes: cell4b = []
note += "%s " % unicode(n) note = " ".join(application.notes)
cell3a = [] cell4a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Status"), stylesheet['Heading4']))
cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Status"), stylesheet['Heading4']))
cell3b = []
if note != "": if note != "":
if application.status == "pub": if application.status == "pub":
cell3b.append(Paragraph(note, stylesheet['Normal'])) cell4b.append(Paragraph(note, stylesheet['Normal']))
else: else:
cell3b.append(Paragraph("%s | %s" % (application.get_status_display(), note), stylesheet['Normal'])) cell4b.append(Paragraph("%s | %s" % (application.get_status_display(), note), stylesheet['Normal']))
else: else:
cell3b.append(Paragraph("%s" % application.get_status_display(), stylesheet['Normal'])) cell4b.append(Paragraph("%s" % application.get_status_display(), stylesheet['Normal']))
data.append([cell4a, cell4b])
# table
data = []
data.append([cell1a,cell1b])
data.append([cell2a,cell2b])
data.append([cell3a,cell3b])
# Version number (aid) # Version number (aid)
if application.public_version.aid > 1: if application.public_version.aid > 1:
cell4a = [] cell5a = []
cell4a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Version"), stylesheet['Heading4'])) cell5b = []
cell4b = [] cell5a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Version"), stylesheet['Heading4']))
cell4b.append(Paragraph("%s" % application.public_version.aid, stylesheet['Normal'])) cell5b.append(Paragraph("%s" % application.public_version.aid, stylesheet['Normal']))
data.append([cell4a,cell4b]) data.append([cell5a, cell5b])
poll_results = application.get_poll_results()
# voting results # voting results
poll_results = application.get_poll_results()
if poll_results: if poll_results:
cell5a = [] cell6a = []
cell5a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Vote results"), stylesheet['Heading4'])) cell6a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Vote results"), stylesheet['Heading4']))
cell5b = [] cell6b = []
ballotcounter = 0 ballotcounter = 0
for result in poll_results: for result in poll_results:
ballotcounter += 1 ballotcounter += 1
if len(poll_results) > 1: if len(poll_results) > 1:
cell5b.append(Paragraph("%s. %s" % (ballotcounter, _("Vote")), stylesheet['Bold'])) cell6b.append(Paragraph("%s. %s" % (ballotcounter, _("Vote")), stylesheet['Bold']))
cell5b.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'])) cell6b.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']))
cell5b.append(Spacer(0,0.2*cm)) cell6b.append(Spacer(0, 0.2*cm))
data.append([cell5a,cell5b]) data.append([cell6a, cell6b])
t=Table(data) # Creating Table
t._argW[0]=4.5*cm t = Table(data)
t._argW[1]=11*cm t._argW[0] = 4.5 * cm
t.setStyle(TableStyle([ ('BOX', (0,0), (-1,-1), 1, colors.black), t._argW[1] = 11 * cm
('VALIGN', (0,0), (-1,-1), 'TOP'), t.setStyle(TableStyle([('BOX', (0, 0), (-1, -1), 1, colors.black),
])) ('VALIGN', (0,0), (-1,-1), 'TOP')]))
story.append(t) story.append(t)
story.append(Spacer(0,1*cm)) story.append(Spacer(0, 1 * cm))
# title # title
story.append(Paragraph(application.public_version.title, stylesheet['Heading3'])) story.append(Paragraph(application.public_version.title, stylesheet['Heading3']))