- Timestamp:
- 10 Jan 2016, 22:18:06 (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
r13335 r13583 343 343 tabledata = [] 344 344 tableheader = [] 345 contenttitle = []346 345 for i in range(1,7): 347 346 tabledata.append(sorted( … … 409 408 tabledata = [] 410 409 tableheader = [] 411 contenttitle = []412 410 for i in range(1,7): 413 411 tabledata.append(sorted( … … 428 426 ) 429 427 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 430 496 class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): 431 497 """ Page to display course tickets -
main/waeup.uniben/trunk/src/waeup/uniben/students/export.py
r12879 r13583 71 71 sorted(iface_names( 72 72 ICustomStudentOnlinePayment, exclude_attribs=False, 73 omit=['display_item' ]))) + (73 omit=['display_item','formatted_p_date']))) + ( 74 74 'student_id','state','current_session') 75 75 -
main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py
r13085 r13583 18 18 19 19 from zope import schema 20 from zope.interface import Attribute 20 21 from waeup.kofa.interfaces import validate_email 21 22 from kofacustom.nigeria.students.interfaces import ( … … 81 82 """ 82 83 84 formatted_p_date = Attribute("Formatted pyment date") 85 83 86 p_current = schema.Bool( 84 87 title = _(u'Current Session Payment'), -
main/waeup.uniben/trunk/src/waeup/uniben/students/payments.py
r9993 r13583 20 20 """ 21 21 import grok 22 from datetime import datetime 23 from zope.component import getUtility 22 24 from zope.component.interfaces import IFactory 23 25 from zope.interface import implementedBy 26 from waeup.kofa.interfaces import IKofaUtils 24 27 from waeup.kofa.students.interfaces import IStudentNavigation 25 28 from waeup.kofa.students.payments import ( 26 29 StudentOnlinePayment, StudentOnlinePaymentFactory) 27 from waeup.kofa.utils.helpers import attrs_to_fields 30 from waeup.kofa.utils.helpers import attrs_to_fields, to_timezone 28 31 from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment 29 32 … … 47 50 return self.__parent__.__parent__ 48 51 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 49 65 CustomStudentOnlinePayment = attrs_to_fields( 50 66 CustomStudentOnlinePayment, omit=['display_item']) -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r13460 r13583 20 20 import tempfile 21 21 import pytz 22 from time import time 22 23 from datetime import datetime, timedelta, date 23 24 from StringIO import StringIO … … 1043 1044 self.assertEqual(self.student['payments'][value].amount_auth, 987.0) 1044 1045 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.