Changeset 6363 for main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Timestamp:
- 13 Jun 2011, 07:34:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r6360 r6363 529 529 grok.require('waeup.handleApplication') 530 530 icon = 'actionicon_pdf.png' 531 text = ' Download pdfslip'531 text = 'Application slip' 532 532 target = 'application_slip.pdf' 533 533 … … 540 540 form_fields = grok.AutoFields(IApplicant).omit( 541 541 'locked').omit('course_admitted') 542 #form_fields['passport'].custom_widget = ThumbnailWidget543 542 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 544 545 543 prefix = 'form' 544 545 @property 546 def label(self): 547 container_title = self.context.__parent__.title 548 return '%s Application Record' % container_title 546 549 547 550 def getCourseAdmitted(self): … … 564 567 ) 565 568 566 # Render a demo pdf page567 569 def render(self): 568 570 from reportlab.pdfgen import canvas … … 570 572 from reportlab.lib.pagesizes import A4, landscape 571 573 from reportlab.lib.styles import getSampleStyleSheet 572 from reportlab.platypus import Frame, Paragraph, Image 574 from reportlab.platypus import (Frame, Paragraph, Image, 575 Table, Spacer) 576 from reportlab.platypus.flowables import HRFlowable 573 577 574 578 pdf = canvas.Canvas('application_slip.pdf',pagesize=A4) 575 579 width, height = A4 576 580 style = getSampleStyleSheet() 581 577 582 story = [] 578 frame = Frame(1*cm,1*cm,width-(2*cm),height-(2*cm)) 583 frame_header = Frame(1*cm,1*cm,width-(4*cm),height-(1*cm)) 584 header_title = getattr(grok.getSite(), 'name', u'Sample University') 585 story.append(Paragraph(header_title, style["Heading1"])) 586 #import pdb; pdb.set_trace() 587 frame_header.addFromList(story,pdf) 588 589 story = [] 590 frame_body = Frame(1*cm,1*cm,width-(4*cm),height-(3*cm)) 591 story.append(Paragraph(self.label, style["Title"])) 592 story.append(HRFlowable()) 593 story.append(Spacer(1, 24)) 594 579 595 self.setUpWidgets() 580 596 597 data = [] 581 598 for widget in self.widgets: 599 f_label = '<font size=12>%s</font>' % widget.label.strip() 600 f_label = Paragraph(f_label, style["Normal"]) 582 601 if widget.name != 'form.passport': 583 ptext = widget() 584 story.append(Paragraph(ptext, style["Normal"])) 602 f_text = '<font size=12>%s</font>' % widget() 603 f_text = Paragraph(f_text, style["Normal"]) 604 data.append([f_label,f_text]) 585 605 else: 586 #import pdb; pdb.set_trace()587 606 filename = widget._data.file.name 588 607 im = Image(filename) 589 story.append(im) 590 frame.addFromList(story,pdf) 608 data.append([f_label,im]) 609 f_label = '<font size=12>Admitted Course of Study</font>' 610 f_text = '<font size=12>%s</font>' % self.getCourseAdmitted() 611 f_label = Paragraph(f_label, style["Normal"]) 612 f_text = Paragraph(f_text, style["Normal"]) 613 data.append([f_label,f_text]) 614 table = Table(data) 615 story.append(table) 616 frame_body.addFromList(story,pdf) 617 591 618 self.response.setHeader( 592 619 'Content-Type', 'application/pdf')
Note: See TracChangeset for help on using the changeset viewer.