Changeset 9555 for main/waeup.kofa/trunk


Ignore:
Timestamp:
6 Nov 2012, 10:54:46 (12 years ago)
Author:
uli
Message:

Henriks wishlist.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/interfaces.py

    r9546 r9555  
    180180        """
    181181    def create_pdf(data, headerline=None, title=None, author=None,
    182                    footer='', note=None, sig_in_footer=False):
     182                   footer='', note=None, sigs_in_footer=[]):
    183183        """Create a PDF.
    184184
     
    196196        page numbers.
    197197
    198         `sig_in_footer`, if set to ``True`` renders signature boxes
    199         above the footer on each page.
     198        `sigs_in_footer` is a set of translateable strings that will be
     199        rendered into signature boxes at bottom of each page.
    200200
    201201        If no `headerline` is given, a default will be rendered (name
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py

    r9547 r9555  
    208208        canvas.saveState()
    209209        canvas.setFont("Helvetica", 10)
    210         canvas.drawString(
    211             2.2*cm + 0.2*cm, 1.35 * inch,
    212             translate(_('Date, Student Signature')))
    213         canvas.drawString(
    214             width/2.0 + 0.15*cm + 0.4*cm, 1.35 * inch,
    215             translate(_('Date, Clearance Officer Signature')))
    216         canvas.rect(2.2*cm, 0.75*inch, width/2.0-2.1*cm, 0.75*inch)
    217         canvas.rect(width/2.0+0.3*cm, 0.75*inch, width/2.0-2.5*cm, 0.75*inch)
     210        mystring = "%r" % ([translate(sig) for sig in signatures])
     211        for num, sig in enumerate(signatures):
     212            box_width = (width - 4.2*cm) / len(signatures)
     213            x_box = 2.1*cm + (box_width) * num
     214            y_box = 0.75*inch
     215            canvas.rect(x_box+0.1*cm, y_box, box_width-0.2*cm, 0.75*inch)
     216            canvas.drawString(
     217                x_box+0.2*cm, 1.35*inch, translate(sig))
    218218        canvas.restoreState()
    219219        return canvas
     
    361361        # Footer
    362362        canvas.saveState()
    363         if getattr(doc, 'sig_in_footer', False):
    364             self._drawSignatureBoxes(canvas, width, height)
     363        if getattr(doc, 'sigs_in_footer', False):
     364            self._drawSignatureBoxes(
     365                canvas, width, height, doc.sigs_in_footer)
    365366        canvas.line(2.2*cm, 0.62*inch, width-2.2*cm, 0.62*inch)
    366367        canvas.setFont("Helvetica", 9)
     
    384385
    385386    def create_pdf(self, data, headerline=None, title=None, author=None,
    386                    footer='', note=None, sig_in_footer=False):
     387                   footer='', note=None, sigs_in_footer=[]):
    387388        """Returns a binary data stream which is a PDF document.
    388389        """
    389390        pdf_stream = StringIO()
    390         bottomMargin = sig_in_footer and 1.4*inch or 0.8*inch
     391        bottomMargin = len(sigs_in_footer) and 1.9*inch or 1.2*inch
    391392        doc = SimpleDocTemplate(
    392393            pdf_stream,
     
    403404        doc.kofa_author = author
    404405        doc.kofa_footer = footer
    405         doc.sig_in_footer = sig_in_footer
     406        doc.sigs_in_footer = sigs_in_footer
    406407        if note is not None:
    407408            html = format_html(note)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9553 r9555  
    639639        return
    640640
    641     def _sigInFooter(self):
     641    def _sigsInFooter(self):
    642642        isStudent = getattr(
    643643            self.request.principal, 'user_type', None) == 'student'
    644644        if not isStudent and self.context.state in (CLEARED, ):
    645             return True
     645            return (_('Date, Student Signature'),
     646                    _('Date, Clearance Officer Signature'),
     647                    )
    646648        return False
    647649
     
    653655            self, 'clearance_slip.pdf',
    654656            self.context.student, studentview, signatures=self._signatures(),
    655             sig_in_footer=self._sigInFooter())
     657            sigs_in_footer=self._sigsInFooter())
    656658
    657659class StudentClearanceManageFormPage(KofaEditFormPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9550 r9555  
    506506    def renderPDF(self, view, filename='slip.pdf', student=None,
    507507                  studentview=None, tableheader=None, tabledata=None,
    508                   note=None, signatures=None, sig_in_footer=False,
     508                  note=None, signatures=None, sigs_in_footer=(),
    509509                  show_scans=True):
    510510        """Render pdf slips for various pages.
     
    559559
    560560        # Insert signatures
    561         if signatures and not sig_in_footer:
     561        if signatures and not sigs_in_footer:
    562562            data.append(Spacer(1, 20))
    563563            signaturetable = get_signature_table(signatures)
     
    569569            pdf_stream = creator.create_pdf(
    570570                data, None, doc_title, author=author, footer=footer_text,
    571                 note=note, sig_in_footer=sig_in_footer)
     571                note=note, sigs_in_footer=sigs_in_footer)
    572572        except IOError:
    573573            view.flash('Error in image file.')
Note: See TracChangeset for help on using the changeset viewer.