Changeset 9010


Ignore:
Timestamp:
17 Jul 2012, 08:38:17 (12 years ago)
Author:
Henrik Bettermann
Message:

Show history on clearance slip.

Render signatures.

Remove unused function.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

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

    r8983 r9010  
    470470            + ' %s' % self.context.display_fullname
    471471
     472    def _signatures(self):
     473        if self.context.state == CLEARED:
     474            return (_('Student Signature'), _('Clearance Officer Signature'))
     475        return
     476
    472477    def render(self):
    473478        studentview = StudentBaseDisplayFormPage(self.context.student,
     
    476481        return students_utils.renderPDF(
    477482            self, 'clearance.pdf',
    478             self.context.student, studentview)
     483            self.context.student, studentview, signatures=self._signatures())
    479484
    480485class StudentClearanceManageFormPage(KofaEditFormPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9005 r9010  
    165165    return table
    166166
     167def render_signatures(signatures, lang='en'):
     168    style = getSampleStyleSheet()
     169    data = []
     170    datetitle = Paragraph(trans(_('Date:'), lang), style["Normal"])
     171    line = []
     172    for signature in signatures:
     173        line.append(datetitle)
     174    data.append(line)
     175    line = []
     176    for signature in signatures:
     177        signature = Paragraph(trans(signature, lang), style["Normal"])
     178        line.append(signature)
     179    data.append(line)
     180    table = Table(data, style=SLIP_STYLE)
     181    return table
     182
    167183def docs_as_flowables(view, lang='en'):
    168184    """Create reportlab flowables out of scanned docs.
     
    201217            data.append(Table(table_data, style=SLIP_STYLE))
    202218    return data
    203 
    204 def insert_footer(pdf,width,style,text=None, number_of_pages=1):
    205       """Render the whole footer frame.
    206       """
    207       story = []
    208       frame_footer = Frame(1*cm,0,width-(2*cm),1*cm)
    209       tz = getUtility(IKofaUtils).tzinfo
    210       timestamp = now(tz).strftime("%d/%m/%Y %H:%M:%S %Z")
    211       left_text = '<font size=10>%s</font>' % timestamp
    212       story.append(Paragraph(left_text, style["Normal"]))
    213       frame_footer.addFromList(story,pdf)
    214       story = []
    215       frame_footer = Frame(1*cm,0,width-(2*cm),1*cm)
    216       portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    217       right_text = translate(_('<font size=10>${a} Page ${b} of ${c}</font>',
    218           mapping = {'a':text, 'b':pdf.getPageNumber(), 'c':number_of_pages}),
    219           'waeup.kofa', target_language=portal_language)
    220       story.append(Paragraph(right_text, style["Right"]))
    221       frame_footer.addFromList(story,pdf)
    222219
    223220class StudentsUtils(grok.GlobalUtility):
     
    355352    def renderPDF(self, view, filename='slip.pdf', student=None,
    356353                  studentview=None, tableheader=None, tabledata=None,
    357                   note=None):
     354                  note=None, signatures=None):
    358355        """Render pdf slips for various pages.
    359356        """
     
    371368            footer_text = "%s - %s - " % (student.student_id, footer_text)
    372369
     370        # Insert history
     371        data.extend(creator.fromStringList(student.history.messages))
     372
    373373        # Insert student data table
    374374        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     
    397397            contenttable = render_table_data(tableheader,tabledata)
    398398            data.append(contenttable)
     399
     400        # Insert signatures
     401        if signatures is not None:
     402            data.append(Spacer(1, 20))
     403            signaturetable = render_signatures(signatures)
     404            data.append(signaturetable)
    399405
    400406        view.response.setHeader(
Note: See TracChangeset for help on using the changeset viewer.