Changeset 7310 for main/waeup.sirp/trunk
- Timestamp:
- 8 Dec 2011, 08:38:02 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7304 r7310 548 548 return students_utils.renderPDF( 549 549 self,'Clearance', 'clearance.pdf', 550 self.context.getStudent , studentview)550 self.context.getStudent(), studentview) 551 551 552 552 class StudentClearanceManageFormPage(WAeUPEditFormPage): … … 781 781 pnav = 4 782 782 783 def update(self): 784 super(StudyLevelDisplayFormPage, self).update() 785 datatable.need() 786 return 787 783 788 @property 784 789 def title(self): … … 825 830 return students_utils.renderPDF( 826 831 self,'Course Registration', 'course_registration.pdf', 827 self.context.getStudent, studentview, 828 tableheader=[('Code','code'), ('Title','title'), 829 ('Department','dcode'), ('Faculty','fcode'), 830 ('Credits', 'credits'), 831 ('Mandatory', 'core_or_elective'), 832 ('Score', 'score'),('Auto', 'automatic') 832 self.context.getStudent(), studentview, 833 tableheader=[('Sem.','semester', 1.5),('Code','code', 2.5), 834 ('Title','title', 5), 835 ('Dept.','dcode', 1.5), ('Faculty','fcode', 1.5), 836 ('Cred.', 'credits', 1.5), 837 ('Mand.', 'core_or_elective', 1.5), 838 ('Score', 'score', 1.5),('Auto', 'automatic', 1.5) 833 839 ], 834 840 tabledata=self.context.values()) … … 1263 1269 students_utils = getUtility(IStudentsUtils) 1264 1270 return students_utils.renderPDF(self,'Payment', 'payment_receipt.pdf', 1265 self.context.getStudent , studentview)1271 self.context.getStudent(), studentview) 1266 1272 1267 1273 # We don't need the display form page yet … … 1484 1490 return students_utils.renderPDF( 1485 1491 self,'Bed Allocation', 'bed_allocation.pdf', 1486 self.context.getStudent , studentview)1492 self.context.getStudent(), studentview) 1487 1493 1488 1494 class RelocateStudentActionButton(ManageActionButton): -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studyleveleditpage.pt
r6808 r7310 20 20 <tr> 21 21 <th> </th> 22 <th>Sem.</th> 22 23 <th>Code</th> 23 24 <th>Title</th> … … 35 36 tal:condition="not: value/core_or_elective" /> 36 37 </td> 38 <td tal:content="value/semester">SEMESTER</td> 37 39 <td> <a tal:attributes="href value/__name__"> 38 40 <span tal:content="value/code">CODE</span> -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studylevelmanagepage.pt
r6806 r7310 62 62 <tr> 63 63 <th> </th> 64 <th>Sem.</th> 64 65 <th>Code</th> 65 66 <th>Title</th> … … 74 75 <tbody> 75 76 <tr tal:repeat="value context/values"> 76 77 <td> 77 78 <input type="checkbox" name="val_id" 78 79 tal:attributes="value value/__name__" /> 79 80 </td> 81 <td tal:content="value/semester">SEMESTER</td> 80 82 <td> <a tal:attributes="href value/__name__"> 81 83 <span tal:content="value/code">CODE</span> -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studylevelpage.pt
r6806 r7310 33 33 <h3>Course Tickets</h3> 34 34 35 <table class=" zebra">35 <table class="display dataTable" > 36 36 <thead> 37 37 <tr> 38 <th>Semester</th> 38 39 <th>Code</th> 39 40 <th>Title</th> … … 48 49 <tbody> 49 50 <tr tal:repeat="value context/values"> 51 <td tal:content="value/semester">SEMESTER</td> 50 52 <td> <a tal:attributes="href value/__name__"> 51 53 <span tal:content="value/code">CODE</span> -
main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py
r7304 r7310 23 23 from reportlab.pdfgen import canvas 24 24 from reportlab.lib.units import cm 25 from reportlab.lib.enums import TA_RIGHT 25 26 from reportlab.lib.pagesizes import A4 26 from reportlab.lib.styles import getSampleStyleSheet 27 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle 27 28 from reportlab.platypus import (Frame, Paragraph, Image, 28 29 Table, Spacer) 29 30 from reportlab.platypus.tables import TableStyle 31 from reportlab.platypus.flowables import PageBreak 30 32 from zope.component import getUtility 31 33 from zope.formlib.form import setUpEditWidgets … … 65 67 ) 66 68 67 def render_student_data(student , studentview):69 def render_student_data(studentview): 68 70 set_up_widgets(studentview, ignore_request=True) 69 71 data = [] … … 89 91 return table 90 92 93 def insert_footer(pdf,width,style,text=None): 94 story = [] 95 frame_footer = Frame(1*cm,0,width-(2*cm),1*cm) 96 timestamp = datetime.now().strftime("%d/%m/%Y %H:%M:%S") 97 left_text = '<font size=10>%s</font>' % timestamp 98 story.append(Paragraph(left_text, style["Normal"])) 99 frame_footer.addFromList(story,pdf) 100 story = [] 101 frame_footer = Frame(1*cm,0,width-(2*cm),1*cm) 102 right_text = '<font size=10>%s Page %s</font>' % ( 103 text, pdf.getPageNumber()) 104 story.append(Paragraph(right_text, style["Right"])) 105 frame_footer.addFromList(story,pdf) 106 91 107 def render_table_data(tableheader,tabledata): 92 108 data = [] … … 96 112 for element in tableheader: 97 113 field = '<strong><font size=10>%s</font></strong>' % element[0] 98 field = Paragraph(field, style[" BodyText"])114 field = Paragraph(field, style["Normal"]) 99 115 line.append(field) 100 116 data.append(line) … … 109 125 # ToDo: The table does not show up if there are too many line 110 126 # and it thus doesn't fit on the page 111 table = Table(data,splitByRow=True,style=CONTENT_STYLE) 127 table = Table(data,colWidths=[ 128 element[2]*cm for element in tableheader],style=CONTENT_STYLE) 112 129 return table 113 130 … … 188 205 pdf.setCreator('WAeUP SIRP') 189 206 width, height = A4 207 footer_text = view.label 208 if student is not None: 209 footer_text = "%s - %s - " % (student.student_id, footer_text) 190 210 style = getSampleStyleSheet() 211 style.add(ParagraphStyle(name='Right', alignment=TA_RIGHT)) 191 212 pdf.line(1*cm,height-(1.8*cm),width-(1*cm),height-(1.8*cm)) 192 213 … … 202 223 203 224 # Insert student data table 204 if student :225 if student is not None: 205 226 story.append(Spacer(1, 12)) 206 studenttable = render_student_data(student , studentview)227 studenttable = render_student_data(studentview) 207 228 story.append(studenttable) 208 229 209 230 story.append(Spacer(1, 12)) 231 #story.append(PageBreak()) 210 232 set_up_widgets(view) 211 233 data = [] … … 247 269 view.flash('Error in image file.') 248 270 return view.redirect(view.url(view.context)) 249 271 insert_footer(pdf,width,style,footer_text) 272 pdf.showPage() 273 frame_body = Frame(1*cm,1*cm,width-(2*cm),height-(1.5*cm)) 250 274 # Insert content table 251 275 if tabledata and tableheader: 252 276 story = [] 253 story.append(Spacer(1, 12))277 #story.append(Spacer(1, 12)) 254 278 contenttable = render_table_data(tableheader,tabledata) 255 279 story.append(contenttable) 256 #import pdb; pdb.set_trace()257 280 frame_body.addFromList(story,pdf) 258 259 story = [] 260 frame_footer = Frame(1*cm,0,width-(2*cm),1*cm) 261 timestamp = datetime.now().strftime("%d/%m/%Y %H:%M:%S") 262 f_text = '<font size=10>%s</font>' % timestamp 263 story.append(Paragraph(f_text, style["Normal"])) 264 frame_footer.addFromList(story,pdf) 281 insert_footer(pdf,width,style,footer_text) 265 282 view.response.setHeader( 266 283 'Content-Type', 'application/pdf')
Note: See TracChangeset for help on using the changeset viewer.