Changeset 12563 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 6 Feb 2015, 14:14:00 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students/reports
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_payment_statistics.py
r12562 r12563 55 55 site = grok.getSite() 56 56 payment_cats = ('clearance', 'gown', 'hostel_maintenance', 'schoolfee') 57 payment_cats = payment_cats + ( u'Total',)57 payment_cats = payment_cats + ('Total',) 58 58 if breakdown == 'faccode': 59 59 codes = tuple(sorted([x for x in site['faculties'].keys()], … … 67 67 codes = tuple(sorted([x for x in depcodes], 68 68 key=lambda x: x.lower())) 69 codes = codes + ( 'Total',)69 codes = codes + (u'Total',) 70 70 # XXX: Here we do _one_ query and then examine the single 71 71 # students. One could also do multiple queries and just look for … … 109 109 # Build table header 110 110 utils = getUtility(IKofaUtils) 111 table_header = ['' for x in xrange(2*len(payment_cats))] 111 112 113 table_header = ['' for x in xrange(len(payment_cats))] 112 114 for cat in payment_cats: 113 115 cat_title = utils.PAYMENT_CATEGORIES.get(cat, cat) 114 table_header[2*payment_cats.index(cat)] = cat_title 115 # turn lists into tuples 116 table_header[payment_cats.index(cat)] = cat_title 117 118 # Convert float into int 119 table = [[int(col) for col in row] for row in table] 120 # Turn lists into tuples 116 121 table = tuple([tuple(row) for row in table]) 117 122 return (codes, table_header, table) … … 124 129 from waeup.kofa.reports import Report 125 130 from waeup.kofa.browser.interfaces import IPDFCreator 131 from waeup.kofa.students.reports.level_report import TTR 126 132 127 133 from waeup.kofa.students.reports.student_statistics import ( 128 134 tbl_data_to_table, STYLE) 129 135 136 def tbl_data_to_table(row_names, col_names, data): 137 result = [] 138 new_col_names = [] 139 for name in col_names: 140 if len(name) > 18: 141 new_col_names.append(name.replace(' ', '\n', 1)) 142 else: 143 new_col_names.append(name) 144 head = [''] + [col_name for col_name in new_col_names] 145 result = [head] 146 for idx, row_name in enumerate(row_names): 147 row = [] 148 i = 0 149 while i < len(data[idx]): 150 row.append("%s (%s)" % (data[idx][i+1], data[idx][i])) 151 i += 2 152 row = [row_name] + row 153 result.append(row) 154 return result 130 155 131 156 TABLE_STYLE = [ … … 136 161 ('FONT', (-1,0), (-1,-1), 'Helvetica-Bold', 8), 137 162 ('ALIGN', (1,1), (-1,-1), 'RIGHT'), 138 ('INNERGRID', (0, 1), (-1,-1), 0.25, colors.black),163 ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), 139 164 ('LINEBELOW', (0,-1), (-1,-1), 0.25, colors.black), 140 ('LINEAFTER', (-1, 1), (-1,-1), 0.25, colors.black),141 ('LINEBEFORE', (-1, 1), (-1,-1), 0.25, colors.black),165 ('LINEAFTER', (-1,0), (-1,-1), 0.25, colors.black), 166 ('LINEBEFORE', (-1,0), (-1,-1), 0.25, colors.black), 142 167 #('LINEABOVE', (0,-1), (-1,-1), 1.0, colors.black), 143 168 #('LINEABOVE', (0,0), (-1,0), 0.25, colors.black), … … 164 189 creator = getUtility(IPDFCreator, name='landscape') 165 190 table_data = tbl_data_to_table(*self.data) 166 col_widths = [None,] + [ 1.6*cm] * len(self.data[1]) + [None,]191 col_widths = [None,] + [3.2*cm] * len(self.data[1]) + [None,] 167 192 pdf_data = [Paragraph('<b>%s</b>' % self.creation_dt_string, 168 193 STYLE["Normal"]), -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_student_payment_statistics.py
r12562 r12563 34 34 result1, 35 35 ((u'fac1', u'Total'), 36 ['Acceptance Fee', ' ', 'Gown Hire Fee', '',37 'Hostel Maintenance Fee', ' ', 'School Fee', '',38 'Total' , ''],39 ((0, 0, 0, 0, 0, 0, 1, 5 .678, 1, 5.678),40 (0, 0, 0, 0, 0, 0, 1, 5 .678, 1, 5.678)))36 ['Acceptance Fee', 'Gown Hire Fee', 37 'Hostel Maintenance Fee', 'School Fee', 38 'Total'], 39 ((0, 0, 0, 0, 0, 0, 1, 5, 1, 5), 40 (0, 0, 0, 0, 0, 0, 1, 5, 1, 5))) 41 41 ) 42 42 self.assertEqual( 43 43 result2, 44 44 ((u'fac1', u'Total'), 45 ['Acceptance Fee', ' ', 'Gown Hire Fee', '',46 'Hostel Maintenance Fee', ' ', 'School Fee', '',47 'Total' , ''],45 ['Acceptance Fee', 'Gown Hire Fee', 46 'Hostel Maintenance Fee', 'School Fee', 47 'Total'], 48 48 ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 49 49 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)))
Note: See TracChangeset for help on using the changeset viewer.