Ignore:
Timestamp:
17 Jun 2013, 07:00:04 (11 years ago)
Author:
Henrik Bettermann
Message:

Apply two-columns design for some base data fields like in students module.

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

Legend:

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

    r10222 r10310  
    2020"""
    2121import grok
    22 from reportlab.platypus import Paragraph, Spacer
     22from reportlab.platypus import Paragraph, Spacer, Table
     23from reportlab.lib.units import cm
    2324from zope.component import getUtility
    2425from zope.i18n import translate
     
    2627from waeup.kofa.browser import DEFAULT_PASSPORT_IMAGE_PATH
    2728from waeup.kofa.browser.interfaces import IPDFCreator
    28 from waeup.kofa.browser.pdf import SMALL_PARA_STYLE
     29from waeup.kofa.browser.pdf import SMALL_PARA_STYLE, ENTRY1_STYLE
    2930from waeup.kofa.interfaces import IExtFileStore, IPDF, IKofaUtils
    3031from waeup.kofa.interfaces import MessageFactory as _
    3132from waeup.kofa.widgets.datewidget import FriendlyDateDisplayWidget
     33
     34SLIP_STYLE = [
     35    ('VALIGN',(0,0),(-1,-1),'TOP'),
     36    #('FONT', (0,0), (-1,-1), 'Helvetica', 11),
     37    ]
    3238
    3339class PDFApplicationSlip(grok.Adapter):
     
    4248
    4349    form_fields =  grok.AutoFields(IApplicant).omit(
    44         'locked', 'course_admitted')
     50        'locked', 'course_admitted', 'suspended',
     51        )
    4552    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     53    column_two_fields = ('applicant_id', 'reg_number',
     54        'firstname', 'middlename', 'lastname')
    4655
    4756    @property
     
    122131        data.append(Spacer(1, 20))
    123132
    124         # append photograph
     133        # create two-column header table
     134        data_left = []
     135        data_right = []
     136        # append photograph to the left
    125137        img_path = getattr(
    126138            getUtility(IExtFileStore).getFileByContext(self.context),
    127139            'name', DEFAULT_PASSPORT_IMAGE_PATH)
    128         data.append(creator.getImage(img_path))
     140        data_left.append([creator.getImage(img_path)])
     141        table_left = Table(data_left,style=SLIP_STYLE)
     142        # append column-two fields to the right
     143        fields = [
     144            field for field in self.form_fields
     145                if field.__name__ in self.column_two_fields]
     146        table_right = creator.getWidgetsTable(
     147            fields, self.context, None, lang=portal_language,
     148            separators=None, colWidths=[5*cm, 6*cm])
     149        header_table = Table([[table_left, table_right],],style=SLIP_STYLE)
     150        data.append(header_table)
     151
    129152        data.append(Spacer(1, 12))
    130153
    131         # append widgets
     154        # append widgets except those already added in column two
    132155        dept, faculty = self._getDeptAndFaculty()
     156        fields = [
     157            field for field in self.form_fields
     158                if not field.__name__ in self.column_two_fields]
    133159        data.append(creator.getWidgetsTable(
    134             self.form_fields, self.context, view, lang=portal_language,
     160            fields, self.context, view, lang=portal_language,
    135161            domain='waeup.kofa', separators=separators,
    136162            course_label='Admitted Course of Study:',
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py

    r9980 r10310  
    625625                        domain='waeup.kofa', separators=None,
    626626                        course_label=None, course_link=None, dept=None,
    627                         faculty=None):
     627                        faculty=None, colWidths=None):
    628628        """Return a reportlab `Table` instance, created from widgets
    629629        determined by `form_fields` and `context`.
     
    687687
    688688        # Create table
    689         table = Table(table_data,style=table_style) #, rowHeights=14)
     689        table = Table(
     690            table_data,style=table_style, colWidths=colWidths) #, rowHeights=14)
    690691        table.hAlign = 'LEFT'
    691692        return table
Note: See TracChangeset for help on using the changeset viewer.