Changeset 10319
- Timestamp:
- 20 Jun 2013, 19:41:56 (12 years ago)
- 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
r10317 r10319 53 53 column_two_fields = ('applicant_id', 'reg_number', 54 54 'firstname', 'middlename', 'lastname') 55 two_columns_design_fields = [] 55 56 56 57 @property … … 132 133 133 134 # create two-column header table 134 data_left = []135 data_right = []136 135 # append photograph to the left 137 136 img_path = getattr( 138 137 getUtility(IExtFileStore).getFileByContext(self.context), 139 138 'name', DEFAULT_PASSPORT_IMAGE_PATH) 140 data_left .append([creator.getImage(img_path)])139 data_left = [[creator.getImage(img_path)]] 141 140 table_left = Table(data_left,style=SLIP_STYLE) 141 142 142 # append column-two fields to the right 143 143 fields = [ … … 150 150 data.append(header_table) 151 151 152 # append two-column table of widgets of those fields defined in 153 # two_columns_design_fields 154 fields = [ 155 field for field in self.form_fields 156 if not field.__name__ in self.column_two_fields and 157 field.__name__ in self.two_columns_design_fields] 158 if fields: 159 data.append(creator.getWidgetsTable( 160 fields, self.context, view, lang=portal_language, 161 domain='waeup.kofa', twoDataCols=True)) 162 152 163 # append widgets except those already added in column two 153 164 dept, faculty = self._getDeptAndFaculty() 154 165 fields = [ 155 166 field for field in self.form_fields 156 if not field.__name__ in self.column_two_fields] 167 if not field.__name__ in self.column_two_fields and 168 not field.__name__ in self.two_columns_design_fields] 157 169 data.append(creator.getWidgetsTable( 158 170 fields, self.context, view, lang=portal_language, -
main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py
r10318 r10319 622 622 return img 623 623 624 def _getWidgetsTableData(self, widgets, 625 separators, domain, lang, table_style):624 def _getWidgetsTableData(self, widgets, separators, domain, 625 lang, table_style, twoDataCols): 626 626 row_num = 0 627 627 table_data = [] 628 628 for widget in widgets: 629 if separators and separators.get(widget.name): 629 # We do not render headlines in multi-column design 630 if twoDataCols is False and separators and separators.get(widget.name): 630 631 f_headline = translate( 631 632 separators[widget.name], domain, target_language=lang) 632 633 f_headline = Paragraph(f_headline, HEADLINE1_STYLE) 633 table_data.append([f_headline 634 table_data.append([f_headline]) 634 635 table_style.append(('SPAN', (0,row_num), (-1,row_num)),) 635 636 table_style.append( … … 676 677 if these are given, we render extra rows with faculty and 677 678 department. 679 - `colWidths` 680 defines the the column widths of the data in the right column 681 of base data (right to the passport image). 678 682 - `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 renders data widgets in a parent table with two columns. 684 """ 685 table_style = [('VALIGN', (0,0), (-1,-1), 'TOP'), 683 686 ] 684 687 widgets = self._setUpWidgets(form_fields, context) … … 686 689 # Determine table data 687 690 table_data, row_num, table_style = self._getWidgetsTableData( 688 widgets, separators, domain, lang, table_style )691 widgets, separators, domain, lang, table_style, twoDataCols) 689 692 690 693 # Add course (admitted, etc.) if applicable … … 696 699 table_data, row_num, dept, faculty, lang, domain) 697 700 698 # Create table 701 # render two-column table of tables 702 lines = len(table_data) 703 middle = lines/2 704 if twoDataCols is True and lines > 2: 705 table_left = Table(table_data[:middle+1], 706 style=table_style, colWidths=[5*cm, 4*cm]) 707 table_right = Table(table_data[middle+1:], 708 style=table_style, colWidths=[5*cm, 4*cm]) 709 table_style.append(('LEFTPADDING', (0,0), (0,-1), 3*cm),) 710 table = Table([[table_left, table_right],],style=table_style) 711 return table 712 713 # render single table 699 714 table = Table( 700 715 table_data,style=table_style, colWidths=colWidths) #, rowHeights=14)
Note: See TracChangeset for help on using the changeset viewer.