Changeset 15798 for main/waeup.kofa
- Timestamp:
- 12 Nov 2019, 10:09:04 (5 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r15710 r15798 4 4 1.6.1.dev0 (unreleased) 5 5 ======================= 6 7 * Add get_bursary_data webservice. 6 8 7 9 * Implement bed selector. -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py
r14681 r15798 5 5 from zope.app.testing.xmlrpc import ServerProxy 6 6 from zope.component import getUtility 7 from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser 7 from waeup.kofa.interfaces import ( 8 IExtFileStore, IFileStoreNameChooser, IKofaUtils) 8 9 from waeup.kofa.testing import FunctionalLayer 10 from waeup.kofa.utils.helpers import to_timezone 9 11 from waeup.kofa.students.payments import StudentOnlinePayment 10 12 from waeup.kofa.students.tests.test_browser import StudentsFullSetup … … 520 522 xmlrpclib.ProtocolError, server.get_student_id, stud_id) 521 523 return 524 525 def test_get_bursary_data(self): 526 tz = getUtility(IKofaUtils).tzinfo 527 payment1 = StudentOnlinePayment() 528 payment1.p_id = 'my-id1' 529 payment1.p_session = 2012 530 payment1.amount_auth = 12.12 531 payment1.p_state = u'paid' 532 payment1.p_category = u'schoolfee' 533 self.student['payments']['my-payment1'] = payment1 534 payment2 = StudentOnlinePayment() 535 payment2.p_id = 'my-id2' 536 payment2.p_session = 2012 537 payment2.amount_auth = 12.12 538 payment2.p_state = u'paid' 539 payment2.p_category = u'clearance' 540 self.student['payments']['my-payment2'] = payment2 541 server = ServerProxy('http://mgr:mgrpw@localhost/app', allow_none=True) 542 result = server.get_bursary_data(None,None,None,None,'dep1') 543 self.assertEqual( 544 result, [ 545 ['K1000000', '234', '123', 'Anna', None, 'Tester', 'created', 546 2004, 2004, None, 'fac1', 'dep1', 'CERT1', 'my-id1', 12.12, 547 'schoolfee', None, 2012, 'paid', 548 str('%s#' % to_timezone(payment1.creation_date, tz)), 'None#'], 549 ['K1000000', '234', '123', 'Anna', None, 'Tester', 550 'created', 2004, 2004, None, 'fac1', 'dep1', 'CERT1', 551 'my-id2', 12.12, 'clearance', None, 2012, 'paid', 552 str('%s#' % to_timezone(payment2.creation_date, tz)), 'None#']] 553 ) 554 REQUEST_XML = """\ 555 <?xml version="1.0"?> 556 <methodCall> 557 <methodName>get_bursary_data</methodName> 558 <params> 559 <param> 560 <value><string></string></value> 561 <value><string></string></value> 562 <value><string></string></value> 563 <value><string></string></value> 564 <value><string>dep1</string></value> 565 </param> 566 </params> 567 </methodCall>""" 568 RESPONSE_XML = """\ 569 <?xml version='1.0'?> 570 <methodResponse> 571 <params> 572 <param> 573 <value><array><data> 574 <value><array><data> 575 <value><string>K1000000</string></value> 576 <value><string>234</string></value> 577 <value><string>123</string></value> 578 <value><string>Anna</string></value> 579 <value><nil/></value><value><string>Tester</string></value> 580 <value><string>created</string></value> 581 <value><int>2004</int></value> 582 <value><int>2004</int></value> 583 <value><nil/></value><value><string>fac1</string></value> 584 <value><string>dep1</string></value> 585 <value><string>CERT1</string></value> 586 <value><string>my-id1</string></value> 587 <value><double>12.12</double></value> 588 <value><string>schoolfee</string></value> 589 <value><nil/></value><value><int>2012</int></value> 590 <value><string>paid</string></value> 591 <value><string>%s</string></value> 592 <value><string>None#</string></value> 593 </data></array></value> 594 <value><array><data> 595 <value><string>K1000000</string></value> 596 <value><string>234</string></value> 597 <value><string>123</string></value> 598 <value><string>Anna</string></value> 599 <value><nil/></value><value><string>Tester</string></value> 600 <value><string>created</string></value> 601 <value><int>2004</int></value> 602 <value><int>2004</int></value> 603 <value><nil/></value><value><string>fac1</string></value> 604 <value><string>dep1</string></value> 605 <value><string>CERT1</string></value> 606 <value><string>my-id2</string></value> 607 <value><double>12.12</double></value> 608 <value><string>clearance</string></value> 609 <value><nil/></value><value><int>2012</int></value> 610 <value><string>paid</string></value> 611 <value><string>%s</string></value> 612 <value><string>None#</string></value> 613 </data></array></value> 614 </data></array></value> 615 </param> 616 </params> 617 </methodResponse> 618 """ 619 xmlout = self.XMLRPC_post(REQUEST_XML) 620 response = RESPONSE_XML % (str('%s#' % to_timezone(payment1.creation_date, tz)), 621 str('%s#' % to_timezone(payment2.creation_date, tz)) 622 ) 623 self.assertEqual(xmlout, response) 624 return -
main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py
r14681 r15798 23 23 from zope.catalog.interfaces import ICatalog 24 24 from waeup.kofa.interfaces import ( 25 IUniversity, IExtFileStore, IFileStoreNameChooser, 25 IUniversity, IExtFileStore, IFileStoreNameChooser, IKofaUtils 26 26 ) 27 from waeup.kofa.utils.helpers import get_fileformat 27 from waeup.kofa.utils.helpers import get_fileformat, to_timezone 28 from waeup.kofa.students.catalog import StudentsQuery 29 from waeup.kofa.students.export import get_payments 28 30 29 31 … … 339 341 result['fingerprints'][num] = xmlrpclib.Binary(fp_file.read()) 340 342 return result 343 344 @grok.require('waeup.xmlrpc') 345 def get_bursary_data(self, 346 current_session=None, current_level=None, certcode=None, 347 current_mode=None, depcode=None): 348 """Returns bursary data of a subset of students. 349 """ 350 if not current_session: 351 current_session = None 352 if not current_level: 353 current_level = None 354 if not depcode: 355 depcode = None 356 if not certcode: 357 certcode = None 358 if not current_mode: 359 current_mode = None 360 hitlist = [] 361 cat = queryUtility(ICatalog, name='students_catalog') 362 results = list( 363 cat.searchResults( 364 current_session=(current_session, current_session), 365 current_level=(current_level, current_level), 366 certcode=(certcode, certcode), 367 current_mode=(current_mode, current_mode), 368 depcode=(depcode, depcode), 369 )) 370 payments = get_payments(results) 371 tz = getUtility(IKofaUtils).tzinfo 372 for payment in payments: 373 hitlist.append( 374 ( 375 payment.student.student_id, 376 payment.student.matric_number, 377 payment.student.reg_number, 378 payment.student.firstname, 379 payment.student.middlename, 380 payment.student.lastname, 381 payment.student.state, 382 payment.student.current_session, 383 payment.student.entry_session, 384 payment.student.entry_mode, 385 payment.student.faccode, 386 payment.student.depcode, 387 payment.student.certcode, 388 payment.p_id, 389 payment.amount_auth, 390 payment.p_category, 391 payment.display_item, 392 payment.p_session, 393 payment.p_state, 394 str('%s#' % to_timezone(payment.creation_date, tz)), 395 str('%s#' % to_timezone(payment.payment_date, tz)), 396 ) 397 ) 398 return hitlist
Note: See TracChangeset for help on using the changeset viewer.