Changeset 7310 for main/waeup.sirp/trunk


Ignore:
Timestamp:
8 Dec 2011, 08:38:02 (13 years ago)
Author:
Henrik Bettermann
Message:

Export course registration slip on two pages.
Set columns width of each column.
Show semester on all course registration view.

ToDo?: Sort course tickets by semester on course registration slip.

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  
    548548        return students_utils.renderPDF(
    549549            self,'Clearance', 'clearance.pdf',
    550             self.context.getStudent, studentview)
     550            self.context.getStudent(), studentview)
    551551
    552552class StudentClearanceManageFormPage(WAeUPEditFormPage):
     
    781781    pnav = 4
    782782
     783    def update(self):
     784        super(StudyLevelDisplayFormPage, self).update()
     785        datatable.need()
     786        return
     787
    783788    @property
    784789    def title(self):
     
    825830        return students_utils.renderPDF(
    826831            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)
    833839                         ],
    834840            tabledata=self.context.values())
     
    12631269        students_utils = getUtility(IStudentsUtils)
    12641270        return students_utils.renderPDF(self,'Payment', 'payment_receipt.pdf',
    1265             self.context.getStudent, studentview)
     1271            self.context.getStudent(), studentview)
    12661272
    12671273# We don't need the display form page yet
     
    14841490        return students_utils.renderPDF(
    14851491            self,'Bed Allocation', 'bed_allocation.pdf',
    1486             self.context.getStudent, studentview)
     1492            self.context.getStudent(), studentview)
    14871493
    14881494class RelocateStudentActionButton(ManageActionButton):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studyleveleditpage.pt

    r6808 r7310  
    2020    <tr>
    2121      <th>&nbsp;</th>
     22      <th>Sem.</th>
    2223      <th>Code</th>
    2324      <th>Title</th>
     
    3536        tal:condition="not: value/core_or_elective" />
    3637      </td>
     38      <td tal:content="value/semester">SEMESTER</td>
    3739      <td> <a tal:attributes="href value/__name__">
    3840      <span tal:content="value/code">CODE</span>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studylevelmanagepage.pt

    r6806 r7310  
    6262    <tr>
    6363      <th>&nbsp;</th>
     64      <th>Sem.</th>
    6465      <th>Code</th>
    6566      <th>Title</th>
     
    7475  <tbody>
    7576    <tr tal:repeat="value context/values">
    76        <td>
     77      <td>
    7778        <input type="checkbox" name="val_id"
    7879                  tal:attributes="value value/__name__" />
    7980      </td>
     81      <td tal:content="value/semester">SEMESTER</td>
    8082      <td> <a tal:attributes="href value/__name__">
    8183      <span tal:content="value/code">CODE</span>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studylevelpage.pt

    r6806 r7310  
    3333<h3>Course Tickets</h3>
    3434
    35 <table class="zebra">
     35<table class="display dataTable" >
    3636  <thead>
    3737    <tr>
     38      <th>Semester</th>
    3839      <th>Code</th>
    3940      <th>Title</th>
     
    4849  <tbody>
    4950    <tr tal:repeat="value context/values">
     51      <td tal:content="value/semester">SEMESTER</td>
    5052      <td> <a tal:attributes="href value/__name__">
    5153      <span tal:content="value/code">CODE</span>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r7304 r7310  
    2323from reportlab.pdfgen import canvas
    2424from reportlab.lib.units import cm
     25from reportlab.lib.enums import TA_RIGHT
    2526from reportlab.lib.pagesizes import A4
    26 from reportlab.lib.styles import getSampleStyleSheet
     27from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
    2728from reportlab.platypus import (Frame, Paragraph, Image,
    2829    Table, Spacer)
    2930from reportlab.platypus.tables import TableStyle
     31from reportlab.platypus.flowables import PageBreak
    3032from zope.component import getUtility
    3133from zope.formlib.form import setUpEditWidgets
     
    6567        )
    6668
    67 def render_student_data(student, studentview):
     69def render_student_data(studentview):
    6870    set_up_widgets(studentview, ignore_request=True)
    6971    data = []
     
    8991    return table
    9092
     93def 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
    91107def render_table_data(tableheader,tabledata):
    92108    data = []
     
    96112    for element in tableheader:
    97113        field = '<strong><font size=10>%s</font></strong>' % element[0]
    98         field = Paragraph(field, style["BodyText"])
     114        field = Paragraph(field, style["Normal"])
    99115        line.append(field)
    100116    data.append(line)
     
    109125    # ToDo: The table does not show up if there are too many line
    110126    # 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)
    112129    return table
    113130
     
    188205        pdf.setCreator('WAeUP SIRP')
    189206        width, height = A4
     207        footer_text = view.label
     208        if student is not None:
     209            footer_text = "%s - %s - " % (student.student_id, footer_text)
    190210        style = getSampleStyleSheet()
     211        style.add(ParagraphStyle(name='Right', alignment=TA_RIGHT))
    191212        pdf.line(1*cm,height-(1.8*cm),width-(1*cm),height-(1.8*cm))
    192213
     
    202223
    203224        # Insert student data table
    204         if student:
     225        if student is not None:
    205226            story.append(Spacer(1, 12))
    206             studenttable = render_student_data(student, studentview)
     227            studenttable = render_student_data(studentview)
    207228            story.append(studenttable)
    208229
    209230        story.append(Spacer(1, 12))
     231        #story.append(PageBreak())
    210232        set_up_widgets(view)
    211233        data = []
     
    247269            view.flash('Error in image file.')
    248270            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))
    250274        # Insert content table
    251275        if tabledata and tableheader:
    252276            story = []
    253             story.append(Spacer(1, 12))
     277            #story.append(Spacer(1, 12))
    254278            contenttable = render_table_data(tableheader,tabledata)
    255279            story.append(contenttable)
    256             #import pdb; pdb.set_trace()
    257280            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)
    265282        view.response.setHeader(
    266283            'Content-Type', 'application/pdf')
Note: See TracChangeset for help on using the changeset viewer.