Changeset 9910


Ignore:
Timestamp:
24 Jan 2013, 10:34:02 (12 years ago)
Author:
Henrik Bettermann
Message:

Condense all pdf slips. Re-use ENTRY1_STYLE in render_student_data.

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

Legend:

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

    r9657 r9910  
    4141NORMAL_STYLE = getSampleStyleSheet()['Normal']
    4242
     43#: A reportlab paragraph style for 'normal' output.
     44HEADING3_STYLE = getSampleStyleSheet()['Heading3']
     45
     46#: A reportlab paragraph style for headings.
     47HEADING_STYLE = ParagraphStyle(
     48    name='Heading3',
     49    parent=HEADING3_STYLE,
     50    fontSize=11,
     51    )
     52
    4353#: A reportlab paragraph style for output of 'code'.
    4454CODE_STYLE = ParagraphStyle(
     
    4757    fontName='Courier',
    4858    fontSize=10,
     59    leading=10,
    4960    )
    5061
     
    5364    name='Entry1',
    5465    parent=NORMAL_STYLE,
    55     fontSize=12,
     66    fontSize=11,
     67    leading=10,
    5668    )
    5769
     
    6072    name='Small1',
    6173    parent=NORMAL_STYLE,
    62     fontSize=10,
     74    fontSize=8,
    6375    )
    6476
     
    6880    parent=NORMAL_STYLE,
    6981    fontName='Helvetica-Bold',
    70     fontSize=12,
     82    fontSize=10,
    7183    )
    7284
     
    7688    parent=NORMAL_STYLE,
    7789    fontName='Helvetica',
    78     fontSize=12,
     90    fontSize=10,
    7991    )
    8092
     
    285297            f_label = translate(widget.label.strip(), domain,
    286298                                target_language=lang)
    287             f_label = Paragraph(f_label, ENTRY1_STYLE)
     299            f_label = Paragraph('%s:' % f_label, ENTRY1_STYLE)
    288300            f_text = translate(widget(), domain, target_language=lang)
    289301            f_text = format_html(f_text)
     
    304316
    305317        # Create table
    306         table = Table(table_data,style=table_style)
     318        table = Table(table_data,style=table_style) #, rowHeights=14)
    307319        table.hAlign = 'LEFT'
    308320        return table
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9907 r9910  
    3333from waeup.kofa.interfaces import MessageFactory as _
    3434from waeup.kofa.students.interfaces import IStudentsUtils
     35from waeup.kofa.browser.pdf import (
     36    ENTRY1_STYLE, format_html, NOTE_STYLE, HEADING_STYLE)
     37from waeup.kofa.browser.interfaces import IPDFCreator
    3538
    3639SLIP_STYLE = [
     
    5356
    5457def formatted_label(color=FONT_COLOR, size=FONT_SIZE):
    55     tag1 ='<font color=%s size=%d>' % (color, size)
     58    tag1 ='<font color=%s>' % (color)
    5659    return tag1 + '%s:</font>'
    5760
     
    9093    text = translate(text, 'zope', target_language=portal_language)
    9194    text = text.replace('</div>', '<br /></div>')
    92     tag1 = u'<font color="%s" size="%d">' % (color, size)
     95    tag1 = u'<font color="%s">' % (color)
    9396    return tag1 + u'%s</font>' % text
    9497
     
    125128
    126129    f_label = formatted_label(size=12) % _('Name')
    127     f_label = Paragraph(f_label, style["Normal"])
     130    f_label = Paragraph(f_label, ENTRY1_STYLE)
    128131    f_text = formatted_text(studentview.context.display_fullname, size=12)
    129     f_text = Paragraph(f_text, style["Normal"])
     132    f_text = Paragraph(f_text, ENTRY1_STYLE)
    130133    data_right.append([f_label,f_text])
    131134
     
    136139            widget.label.strip(), 'waeup.kofa',
    137140            target_language=portal_language)
    138         f_label = Paragraph(f_label, style["Normal"])
     141        f_label = Paragraph(f_label, ENTRY1_STYLE)
    139142        f_text = formatted_text(widget(), size=12)
    140         f_text = Paragraph(f_text, style["Normal"])
     143        f_text = Paragraph(f_text, ENTRY1_STYLE)
    141144        data_right.append([f_label,f_text])
    142145
    143146    if getattr(studentview.context, 'certcode', None):
    144147        f_label = formatted_label(size=12) % _('Study Course')
    145         f_label = Paragraph(f_label, style["Normal"])
     148        f_label = Paragraph(f_label, ENTRY1_STYLE)
    146149        f_text = formatted_text(
    147150            studentview.context['studycourse'].certificate.longtitle(), size=12)
    148         f_text = Paragraph(f_text, style["Normal"])
     151        f_text = Paragraph(f_text, ENTRY1_STYLE)
    149152        data_right.append([f_label,f_text])
    150153
    151154        f_label = formatted_label(size=12) % _('Department')
    152         f_label = Paragraph(f_label, style["Normal"])
     155        f_label = Paragraph(f_label, ENTRY1_STYLE)
    153156        f_text = formatted_text(
    154157            studentview.context[
    155158            'studycourse'].certificate.__parent__.__parent__.longtitle(),
    156159            size=12)
    157         f_text = Paragraph(f_text, style["Normal"])
     160        f_text = Paragraph(f_text, ENTRY1_STYLE)
    158161        data_right.append([f_label,f_text])
    159162
    160163        f_label = formatted_label(size=12) % _('Faculty')
    161         f_label = Paragraph(f_label, style["Normal"])
     164        f_label = Paragraph(f_label, ENTRY1_STYLE)
    162165        f_text = formatted_text(
    163166            studentview.context[
    164167            'studycourse'].certificate.__parent__.__parent__.__parent__.longtitle(),
    165168            size=12)
    166         f_text = Paragraph(f_text, style["Normal"])
     169        f_text = Paragraph(f_text, ENTRY1_STYLE)
    167170        data_right.append([f_label,f_text])
    168171
    169172        f_label = formatted_label(size=12) % _('Entry Session')
    170         f_label = Paragraph(f_label, style["Normal"])
     173        f_label = Paragraph(f_label, ENTRY1_STYLE)
    171174        entry_session = studentview.context['studycourse'].entry_session
    172175        entry_session = academic_sessions_vocab.getTerm(entry_session).title
    173176        f_text = formatted_text(entry_session, size=12)
    174         f_text = Paragraph(f_text, style["Normal"])
     177        f_text = Paragraph(f_text, ENTRY1_STYLE)
    175178        data_right.append([f_label,f_text])
    176179
     
    217220    sig_style = [
    218221        ('VALIGN',(0,-1),(-1,-1),'TOP'),
    219         ('FONT', (0,0), (-1,-1), 'Helvetica-BoldOblique', 12),
     222        #('FONT', (0,0), (-1,-1), 'Helvetica-BoldOblique', 12),
    220223        ('BOTTOMPADDING', (0,0), (-1,0), 36),
    221224        ('TOPPADDING', (0,-1), (-1,-1), 0),
     
    228231    row = []
    229232    for signature in signatures:
    230         row.append(trans(_('Date:'), lang))
     233        row.append(Paragraph(trans(_('Date:'), lang), ENTRY1_STYLE))
    231234        row.append('')
    232235        if len(signatures) > 1:
     
    236239            row.append('') # empty spaceholder on right
    237240    data.append(row[:-1])
    238     data.extend(([''],)*3) # insert 3 empty rows...
     241    data.extend(([''],)*2) # insert 2 empty rows...
    239242    row = []
    240243    for signature in signatures:
    241         row.append(Paragraph(trans(signature, lang), style["Normal"]))
     244        row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
    242245        row.append('')
    243246    data.append(row[:-1])
     
    252255    from waeup.kofa.students.viewlets import FileManager
    253256    from waeup.kofa.browser import DEFAULT_IMAGE_PATH
    254     from waeup.kofa.browser.pdf import NORMAL_STYLE, ENTRY1_STYLE
    255257    style = getSampleStyleSheet()
    256258    data = []
     
    261263    if fm.viewlets:
    262264        sc_translation = trans(_('Scanned Documents'), lang)
    263         data.append(Paragraph(sc_translation, style["Heading3"]))
     265        data.append(Paragraph(sc_translation, HEADING_STYLE))
    264266        # Insert list of scanned documents
    265267        table_data = []
     
    503505        """Render pdf admission letter.
    504506        """
    505         # XXX: we have to fix the import problems here.
    506         from waeup.kofa.browser.interfaces import IPDFCreator
    507         from waeup.kofa.browser.pdf import format_html, NOTE_STYLE
    508507        if student is None:
    509508            return
     
    559558        """Render pdf slips for various pages.
    560559        """
    561         # XXX: we have to fix the import problems here.
    562         from waeup.kofa.browser.interfaces import IPDFCreator
    563         from waeup.kofa.browser.pdf import NORMAL_STYLE, ENTRY1_STYLE
    564560        style = getSampleStyleSheet()
    565561        creator = getUtility(IPDFCreator)
     
    576572        if student is not None:
    577573            bd_translation = trans(_('Base Data'), portal_language)
    578             data.append(Paragraph(bd_translation, style["Heading3"]))
     574            data.append(Paragraph(bd_translation, HEADING_STYLE))
    579575            data.append(render_student_data(studentview))
    580576
    581577        # Insert widgets
    582578        if view.form_fields:
    583             data.append(Paragraph(view.title, style["Heading3"]))
     579            data.append(Paragraph(view.title, HEADING_STYLE))
    584580            portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    585581            separators = getattr(self, 'SEPARATORS_DICT', {})
     
    594590
    595591        # Insert history
    596         if filename.startswith('clearance') or filename.startswith('course'):
     592        if filename.startswith('clearance'):
    597593            hist_translation = trans(_('Workflow History'), portal_language)
    598             data.append(Paragraph(hist_translation, style["Heading3"]))
     594            data.append(Paragraph(hist_translation, HEADING_STYLE))
    599595            data.extend(creator.fromStringList(student.history.messages))
    600596
     
    602598        if tabledata_1 and tableheader_1:
    603599            #data.append(PageBreak())
    604             data.append(Spacer(1, 20))
    605             data.append(Paragraph(view.content_title_1, style["Heading3"]))
     600            #data.append(Spacer(1, 20))
     601            data.append(Paragraph(view.content_title_1, HEADING_STYLE))
    606602            data.append(Spacer(1, 8))
    607603            contenttable = render_table_data(tableheader_1,tabledata_1)
     
    611607        if tabledata_2 and tableheader_2:
    612608            #data.append(PageBreak())
    613             data.append(Spacer(1, 20))
    614             data.append(Paragraph(view.content_title_2, style["Heading3"]))
     609            #data.append(Spacer(1, 20))
     610            data.append(Paragraph(view.content_title_2, HEADING_STYLE))
    615611            data.append(Spacer(1, 8))
    616612            contenttable = render_table_data(tableheader_2,tabledata_2)
Note: See TracChangeset for help on using the changeset viewer.