Changeset 13621
- Timestamp:
- 16 Jan 2016, 16:24:39 (9 years ago)
- 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 343 343 tabledata = [] 344 344 tableheader = [] 345 contenttitle = [] 345 346 for i in range(1,7): 346 347 tabledata.append(sorted( … … 408 409 tabledata = [] 409 410 tableheader = [] 411 contenttitle = [] 410 412 for i in range(1,7): 411 413 tabledata.append(sorted( … … 426 428 ) 427 429 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 = None439 440 @property441 def label(self):442 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE443 return translate(_('Bursary Clearance Slip of'),444 'waeup.kofa', target_language=portal_language) \445 + ' %s' % self.context.display_fullname446 447 def _sigsInFooter(self):448 return (_('Date, Student Signature'),449 _('Date, Bursary Signature'),450 )451 452 @property453 def tabletitle(self):454 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE455 tabletitle = []456 tabletitle.append(translate(_('Successful Payments'), 'waeup.kofa',457 target_language=portal_language))458 return tabletitle459 460 def render(self):461 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE462 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_fields494 )495 496 430 class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): 497 431 """ Page to display course tickets -
main/waeup.uniben/trunk/src/waeup/uniben/students/export.py
r13583 r13621 71 71 sorted(iface_names( 72 72 ICustomStudentOnlinePayment, exclude_attribs=False, 73 omit=['display_item' ,'formatted_p_date']))) + (73 omit=['display_item']))) + ( 74 74 'student_id','state','current_session') 75 75 -
main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py
r13583 r13621 18 18 19 19 from zope import schema 20 from zope.interface import Attribute21 20 from waeup.kofa.interfaces import validate_email 22 21 from kofacustom.nigeria.students.interfaces import ( … … 82 81 """ 83 82 84 formatted_p_date = Attribute("Formatted pyment date")85 86 83 p_current = schema.Bool( 87 84 title = _(u'Current Session Payment'), -
main/waeup.uniben/trunk/src/waeup/uniben/students/payments.py
r13583 r13621 20 20 """ 21 21 import grok 22 from datetime import datetime23 from zope.component import getUtility24 22 from zope.component.interfaces import IFactory 25 23 from zope.interface import implementedBy 26 from waeup.kofa.interfaces import IKofaUtils27 24 from waeup.kofa.students.interfaces import IStudentNavigation 28 25 from waeup.kofa.students.payments import ( 29 26 StudentOnlinePayment, StudentOnlinePaymentFactory) 30 from waeup.kofa.utils.helpers import attrs_to_fields , to_timezone27 from waeup.kofa.utils.helpers import attrs_to_fields 31 28 from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment 32 29 … … 50 47 return self.__parent__.__parent__ 51 48 52 @property53 def formatted_p_date(self):54 if isinstance(self.payment_date, datetime):55 tz = getUtility(IKofaUtils).tzinfo56 try:57 timestamp = to_timezone(58 self.payment_date, tz).strftime("%Y-%m-%d %H:%M:%S")59 except ValueError:60 return None61 return timestamp62 else:63 return None64 65 49 CustomStudentOnlinePayment = attrs_to_fields( 66 50 CustomStudentOnlinePayment, omit=['display_item']) -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r13583 r13621 20 20 import tempfile 21 21 import pytz 22 from time import time23 22 from datetime import datetime, timedelta, date 24 23 from StringIO import StringIO … … 1044 1043 self.assertEqual(self.student['payments'][value].amount_auth, 987.0) 1045 1044 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" % timestamp1051 payment1.p_category = 'schoolfee'1052 payment1.p_item = u'My School Fee'1053 payment1.p_session = 20151054 payment1.p_level = 1001055 payment1.p_current = True1056 payment1.amount_auth = 23456.91057 payment1.approve()1058 payment2 = createObject(u'waeup.StudentOnlinePayment')1059 timestamp = ("%d" % int(time()*10000))[1:]1060 payment2.p_id = "p%s" % timestamp1061 payment2.p_category = 'clearance'1062 payment2.p_item = u'My Clearance Fee'1063 payment2.p_session = 20151064 payment2.p_level = 1001065 payment2.p_current = True1066 payment2.amount_auth = 5678.61067 payment2.approve()1068 self.student['payments'][payment1.p_id] = payment11069 self.student['payments'][payment2.p_id] = payment21070 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" % path1078 return
Note: See TracChangeset for help on using the changeset viewer.