Changeset 13621


Ignore:
Timestamp:
16 Jan 2016, 16:24:39 (9 years ago)
Author:
Henrik Bettermann
Message:

Revert changes from r13583. This will be implemented in kofacustom.nigeria.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r13583 r13621  
    343343        tabledata = []
    344344        tableheader = []
     345        contenttitle = []
    345346        for i in range(1,7):
    346347            tabledata.append(sorted(
     
    408409        tabledata = []
    409410        tableheader = []
     411        contenttitle = []
    410412        for i in range(1,7):
    411413            tabledata.append(sorted(
     
    426428            )
    427429
    428 class UnibenExportPDFBursaryClearancePage(UtilityView, grok.View):
    429     """Deliver a PDF bursary clearance slip.
    430     """
    431     grok.context(ICustomStudent)
    432     grok.name('bursary_clearance_slip.pdf')
    433     grok.require('waeup.viewStudent')
    434     prefix = 'form'
    435 
    436     omit_fields = () # ('date_of_birth', 'current_level')
    437 
    438     form_fields = None
    439 
    440     @property
    441     def label(self):
    442         portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    443         return translate(_('Bursary Clearance Slip of'),
    444             'waeup.kofa', target_language=portal_language) \
    445             + ' %s' % self.context.display_fullname
    446 
    447     def _sigsInFooter(self):
    448         return (_('Date, Student Signature'),
    449                 _('Date, Bursary Signature'),
    450                 )
    451 
    452     @property
    453     def tabletitle(self):
    454         portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    455         tabletitle = []
    456         tabletitle.append(translate(_('Successful Payments'), 'waeup.kofa',
    457             target_language=portal_language))
    458         return tabletitle
    459 
    460     def render(self):
    461         portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    462         P_ID = translate(_('Payment Id'), 'waeup.kofa', target_language=portal_language)
    463         #CD = translate(_('Creation Date'), 'waeup.kofa', target_language=portal_language)
    464         PD = translate(_('Payment Date'), 'waeup.kofa', target_language=portal_language)
    465         CAT = translate(_('Payment Category'), 'waeup.kofa', target_language=portal_language)
    466         ITEM = translate(_('Payment Item'), 'waeup.kofa', target_language=portal_language)
    467         AMT = translate(_('Amount (Naira)'), 'waeup.kofa', target_language=portal_language)
    468         SSS = translate(_('Payment Session'), 'waeup.kofa', target_language=portal_language)
    469         studentview = StudentBasePDFFormPage(self.context.student,
    470             self.request, self.omit_fields)
    471         students_utils = getUtility(IStudentsUtils)
    472 
    473         tabledata = []
    474         tableheader = []
    475         tabledata.append(sorted(
    476             [value for value in self.context['payments'].values()
    477              if value.p_state == 'paid'], key=lambda value: value.p_id))
    478         tableheader.append([(P_ID,'p_id', 3),
    479                          #(CD,'creation_date', 3),
    480                          (PD,'formatted_p_date', 3),
    481                          (CAT,'category', 3),
    482                          (ITEM, 'p_item', 3),
    483                          (AMT, 'amount_auth', 2),
    484                          (SSS, 'p_session', 2),
    485                          ])
    486         return students_utils.renderPDF(
    487             self, 'bursary_clearance_slip.pdf',
    488             self.context.student, studentview,
    489             tableheader=tableheader,
    490             tabledata=tabledata,
    491             signatures=None,
    492             sigs_in_footer=self._sigsInFooter(),
    493             omit_fields=self.omit_fields
    494             )
    495 
    496430class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage):
    497431    """ Page to display course tickets
  • main/waeup.uniben/trunk/src/waeup/uniben/students/export.py

    r13583 r13621  
    7171        sorted(iface_names(
    7272            ICustomStudentOnlinePayment, exclude_attribs=False,
    73             omit=['display_item','formatted_p_date']))) + (
     73            omit=['display_item']))) + (
    7474            'student_id','state','current_session')
    7575
  • main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py

    r13583 r13621  
    1818
    1919from zope import schema
    20 from zope.interface import Attribute
    2120from waeup.kofa.interfaces import validate_email
    2221from kofacustom.nigeria.students.interfaces import (
     
    8281    """
    8382
    84     formatted_p_date = Attribute("Formatted pyment date")
    85 
    8683    p_current = schema.Bool(
    8784        title = _(u'Current Session Payment'),
  • main/waeup.uniben/trunk/src/waeup/uniben/students/payments.py

    r13583 r13621  
    2020"""
    2121import grok
    22 from datetime import datetime
    23 from zope.component import getUtility
    2422from zope.component.interfaces import IFactory
    2523from zope.interface import implementedBy
    26 from waeup.kofa.interfaces import IKofaUtils
    2724from waeup.kofa.students.interfaces import IStudentNavigation
    2825from waeup.kofa.students.payments import (
    2926    StudentOnlinePayment, StudentOnlinePaymentFactory)
    30 from waeup.kofa.utils.helpers import attrs_to_fields, to_timezone
     27from waeup.kofa.utils.helpers import attrs_to_fields
    3128from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment
    3229
     
    5047        return self.__parent__.__parent__
    5148
    52     @property
    53     def formatted_p_date(self):
    54         if isinstance(self.payment_date, datetime):
    55             tz = getUtility(IKofaUtils).tzinfo
    56             try:
    57                 timestamp = to_timezone(
    58                     self.payment_date, tz).strftime("%Y-%m-%d %H:%M:%S")
    59             except ValueError:
    60                 return None
    61             return timestamp
    62         else:
    63             return None
    64 
    6549CustomStudentOnlinePayment = attrs_to_fields(
    6650    CustomStudentOnlinePayment, omit=['display_item'])
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r13583 r13621  
    2020import tempfile
    2121import pytz
    22 from time import time
    2322from datetime import datetime, timedelta, date
    2423from StringIO import StringIO
     
    10441043        self.assertEqual(self.student['payments'][value].amount_auth, 987.0)
    10451044        return
    1046 
    1047     def test_bursary_pdf_slip(self):
    1048         payment1 = createObject(u'waeup.StudentOnlinePayment')
    1049         timestamp = ("%d" % int(time()*10000))[1:]
    1050         payment1.p_id = "p%s" % timestamp
    1051         payment1.p_category = 'schoolfee'
    1052         payment1.p_item = u'My School Fee'
    1053         payment1.p_session = 2015
    1054         payment1.p_level = 100
    1055         payment1.p_current = True
    1056         payment1.amount_auth = 23456.9
    1057         payment1.approve()
    1058         payment2 = createObject(u'waeup.StudentOnlinePayment')
    1059         timestamp = ("%d" % int(time()*10000))[1:]
    1060         payment2.p_id = "p%s" % timestamp
    1061         payment2.p_category = 'clearance'
    1062         payment2.p_item = u'My Clearance Fee'
    1063         payment2.p_session = 2015
    1064         payment2.p_level = 100
    1065         payment2.p_current = True
    1066         payment2.amount_auth = 5678.6
    1067         payment2.approve()
    1068         self.student['payments'][payment1.p_id] = payment1
    1069         self.student['payments'][payment2.p_id] = payment2
    1070         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1071         self.browser.open(self.student_path + '/bursary_clearance_slip.pdf')
    1072         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    1073         self.assertEqual(self.browser.headers['Content-Type'],
    1074                          'application/pdf')
    1075         path = os.path.join(samples_dir(), 'bursary_clearance_slip.pdf')
    1076         open(path, 'wb').write(self.browser.contents)
    1077         print "Sample PDF bursary_clearance_slip.pdf written to %s" % path
    1078         return
Note: See TracChangeset for help on using the changeset viewer.