Ignore:
Timestamp:
20 Jun 2013, 13:43:56 (12 years ago)
Author:
Henrik Bettermann
Message:

Define private method to collect widgets table data in getWidgetsTable.

File:
1 edited

Legend:

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

    r10310 r10318  
    622622        return img
    623623
    624     def getWidgetsTable(self, form_fields, context, view, lang='en',
    625                         domain='waeup.kofa', separators=None,
    626                         course_label=None, course_link=None, dept=None,
    627                         faculty=None, colWidths=None):
    628         """Return a reportlab `Table` instance, created from widgets
    629         determined by `form_fields` and `context`.
    630 
    631         - `form_fields`
    632            is a list of schema fields as created by grok.AutoFields.
    633         - `context`
    634            is some object whose content is rendered here.
    635         - `view`
    636            is currently not used but supposed to be a view which is
    637            actually rendering a PDF document.
    638         - `lang`
    639            the portal language. Used for translations of strings.
    640         - `domain`
    641            the translation domain used for translations of strings.
    642         - `separators`
    643            a list of separators.
    644         - `course_label` and `course_link`
    645            if a course should be added to the table, `course_label`
    646            and `course_link` can be given, both being strings. They
    647            will be rendered in an extra-row.
    648         - `dept` and `faculty`
    649            if these are given, we render extra rows with faculty and
    650            department.
    651         """
     624    def _getWidgetsTableData(self, widgets,
     625                             separators, domain, lang, table_style):
     626        row_num = 0
    652627        table_data = []
    653         table_style = [#('LEFTPADDING', (0,0), (0,-1), 0), # indentation
    654                        ('VALIGN', (0,0), (-1,-1), 'TOP'),
    655                        ]
    656         row_num = 0
    657         widgets = self._setUpWidgets(form_fields, context)
    658628        for widget in widgets:
    659629            if separators and separators.get(widget.name):
     
    677647            table_data.append([f_label,f_text])
    678648            row_num += 1
     649        return table_data, row_num, table_style
     650
     651    def getWidgetsTable(self, form_fields, context, view, lang='en',
     652                        domain='waeup.kofa', separators=None,
     653                        course_label=None, course_link=None, dept=None,
     654                        faculty=None, colWidths=None, twoDataCols=False):
     655        """Return a reportlab `Table` instance, created from widgets
     656        determined by `form_fields` and `context`.
     657
     658        - `form_fields`
     659           is a list of schema fields as created by grok.AutoFields.
     660        - `context`
     661           is some object whose content is rendered here.
     662        - `view`
     663           is currently not used but supposed to be a view which is
     664           actually rendering a PDF document.
     665        - `lang`
     666           the portal language. Used for translations of strings.
     667        - `domain`
     668           the translation domain used for translations of strings.
     669        - `separators`
     670           a list of separators.
     671        - `course_label` and `course_link`
     672           if a course should be added to the table, `course_label`
     673           and `course_link` can be given, both being strings. They
     674           will be rendered in an extra-row.
     675        - `dept` and `faculty`
     676           if these are given, we render extra rows with faculty and
     677           department.
     678        - `twoDataCols`
     679           render widgets in a parent table with two columns.
     680        """
     681        table_style = [#('LEFTPADDING', (0,0), (0,-1), 0), # indentation
     682                       ('VALIGN', (0,0), (-1,-1), 'TOP'),
     683                       ]
     684        widgets = self._setUpWidgets(form_fields, context)
     685
     686        # Determine table data
     687        table_data, row_num, table_style = self._getWidgetsTableData(
     688            widgets, separators, domain, lang, table_style)
    679689
    680690        # Add course (admitted, etc.) if applicable
Note: See TracChangeset for help on using the changeset viewer.