Changeset 15042 for main/waeup.kofa/trunk
- Timestamp:
- 6 Jun 2018, 11:10:07 (7 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r15037 r15042 4 4 1.6.1.dev0 (unreleased) 5 5 ======================= 6 7 * Fix `CourseTicketExporter`. Ticket level and session filter 8 did not work. 9 10 * Add payment category filter to payment exporters. 6 11 7 12 * Remove 'hidden' attribute from ordereddSelectionList which has -
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r15032 r15042 220 220 if not job.kwargs.has_key('selected'): 221 221 args = ', '.join(['%s=%s' % (item[0], item[1]) 222 for item in job.kwargs.items()]) 222 for item in job.kwargs.items() 223 if item[1] not in ('all', '', None)]) 223 224 else: 224 225 args = 'selection' -
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r14939 r15042 447 447 self.assertTrue( 448 448 'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig ' 449 '- exported: students (None, None, None, None, None, None, None, None), ' 449 '- exported: students ' 450 '(None, None, None, None, None, None, , , all, all, all), ' 450 451 'job_id=%s' 451 452 % job_id in logcontent) -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r14983 r15042 3371 3371 def _set_session_values(self): 3372 3372 vocab_terms = academic_sessions_vocab.by_value.values() 3373 self.sessions = sorted( 3373 self.sessions = [(_('All Sessions'), 'all')] 3374 self.sessions += sorted( 3374 3375 [(x.title, x.token) for x in vocab_terms], reverse=True) 3375 self.sessions += [(_('All Sessions'), 'all')]3376 3376 return 3377 3377 3378 3378 def _set_level_values(self): 3379 3379 vocab_terms = course_levels.by_value.values() 3380 self.levels = sorted( 3380 self.levels = [(_('All Levels'), 'all')] 3381 self.levels += sorted( 3381 3382 [(x.title, x.token) for x in vocab_terms]) 3382 self.levels += [(_('All Levels'), 'all')]3383 3383 return 3384 3384 3385 3385 def _set_mode_values(self): 3386 3386 utils = getUtility(IKofaUtils) 3387 self.modes = sorted([(value, key) for key, value in 3387 self.modes =[(_('All Modes'), 'all')] 3388 self.modes += sorted([(value, key) for key, value in 3388 3389 utils.STUDY_MODES_DICT.items()]) 3389 self.modes +=[(_('All Modes'), 'all')] 3390 return 3391 3392 def _set_paycat_values(self): 3393 utils = getUtility(IKofaUtils) 3394 self.paycats =[(_('All Payment Categories'), 'all')] 3395 self.paycats += sorted([(value, key) for key, value in 3396 utils.PAYMENT_CATEGORIES.items()]) 3390 3397 return 3391 3398 … … 3426 3433 3427 3434 def update(self, START=None, session=None, level=None, mode=None, 3428 payments_start=None, payments_end=None, 3429 exporter=None):3435 payments_start=None, payments_end=None, ct_level=None, 3436 ct_session=None, paycat=None, exporter=None): 3430 3437 self._set_session_values() 3431 3438 self._set_level_values() 3432 3439 self._set_mode_values() 3440 self._set_paycat_values() 3433 3441 self._set_exporter_values() 3434 3442 if START is None: … … 3453 3461 if mode == 'all': 3454 3462 mode = None 3455 if payments_start == '':3456 payments_start = None3457 if payments_end == '':3458 payments_end = None3459 3463 if (mode, 3460 3464 level, … … 3464 3468 self.certcode) == (None, None, None, None, None, None): 3465 3469 # Export all students including those without certificate 3466 if payments_start: 3467 job_id = self.context.start_export_job(exporter, 3468 self.request.principal.id, 3469 payments_start = payments_start, 3470 payments_end = payments_end) 3471 else: 3472 job_id = self.context.start_export_job(exporter, 3473 self.request.principal.id) 3474 else: 3475 if payments_start: 3476 job_id = self.context.start_export_job(exporter, 3477 self.request.principal.id, 3478 current_session=session, 3479 current_level=level, 3480 current_mode=mode, 3481 faccode=self.faccode, 3482 depcode=self.depcode, 3483 certcode=self.certcode, 3484 payments_start = payments_start, 3485 payments_end = payments_end) 3486 else: 3487 job_id = self.context.start_export_job(exporter, 3488 self.request.principal.id, 3489 current_session=session, 3490 current_level=level, 3491 current_mode=mode, 3492 faccode=self.faccode, 3493 depcode=self.depcode, 3494 certcode=self.certcode) 3470 job_id = self.context.start_export_job(exporter, 3471 self.request.principal.id, 3472 payments_start = payments_start, 3473 payments_end = payments_end, 3474 paycat=paycat, 3475 ct_level = ct_level, 3476 ct_session = ct_session, 3477 ) 3478 else: 3479 job_id = self.context.start_export_job(exporter, 3480 self.request.principal.id, 3481 current_session=session, 3482 current_level=level, 3483 current_mode=mode, 3484 faccode=self.faccode, 3485 depcode=self.depcode, 3486 certcode=self.certcode, 3487 payments_start = payments_start, 3488 payments_end = payments_end, 3489 paycat=paycat, 3490 ct_level = ct_level, 3491 ct_session = ct_session,) 3495 3492 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 3496 3493 self.context.logger.info( 3497 '%s - exported: %s (%s, %s, %s, %s, %s, %s, %s, %s ), job_id=%s'3494 '%s - exported: %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s), job_id=%s' 3498 3495 % (ob_class, exporter, session, level, mode, self.faccode, 3499 self.depcode, self.certcode, payments_start, payments_end, job_id)) 3496 self.depcode, self.certcode, payments_start, payments_end, 3497 ct_level, ct_session, paycat, job_id)) 3500 3498 self.flash(_('Export started for students with') + 3501 3499 ' current_session=%s, current_level=%s, study_mode=%s' % ( -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportconfig.pt
r14984 r15042 67 67 </span> 68 68 69 <span id="paycat" style="display: none;"> 70 <br /> 71 <label for="paycat" i18n:translate=""> 72 Payment Categories 73 </label> 74 <select name="paycat" class="form-control half"> 75 <option tal:repeat="item view/paycats" 76 tal:attributes="value python:item[1]"> 77 <span tal:replace="python: item[0]">schoolfee</span> 78 </option> 79 </select> 80 <br /> 81 </span> 69 82 70 83 <span id="ct_data" style="display: none;"> … … 91 104 <br /> 92 105 </span> 106 93 107 <br /> 94 108 … … 104 118 document.getElementById('exporter').value == 'studentunpaidpayments') { 105 119 document.getElementById('payment_dates').style.display = 'block'; 120 document.getElementById('paycat').style.display = 'block'; 106 121 document.getElementById('ct_data').style.display = 'none'; 107 122 } else if (document.getElementById('exporter').value == 'coursetickets') { 108 123 document.getElementById('ct_data').style.display = 'block'; 109 124 document.getElementById('payment_dates').style.display = 'none'; 125 document.getElementById('paycat').style.display = 'none'; 110 126 } else { 111 127 document.getElementById('ct_data').style.display = 'none'; 112 128 document.getElementById('payment_dates').style.display = 'none'; 129 document.getElementById('paycat').style.display = 'none'; 113 130 } 114 131 } -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r14984 r15042 135 135 payments_start = kw.get('payments_start') 136 136 payments_end = kw.get('payments_end') 137 if payments_start and payments_end: 138 # Payment period given 139 payments_start = datetime.strptime(payments_start, date_format) 140 payments_end = datetime.strptime(payments_end, date_format) 141 tz = getUtility(IKofaUtils).tzinfo 142 payments_start = tz.localize(payments_start) 143 payments_end = tz.localize(payments_end) + timedelta(days=1) 144 if p_states: 145 # Only tickets in certain states and payment period are considered 146 for student in students: 147 for payment in student.get('payments', {}).values(): 148 if payment.payment_date and payment.p_state in p_states: 149 payment_date = to_timezone(payment.payment_date, tz) 150 if payment_date > payments_start and \ 151 payment_date < payments_end: 152 payments.append(payment) 153 else: 154 # All tickets in payment period are considered 155 for student in students: 156 for payment in student.get('payments', {}).values(): 157 if payment.payment_date: 158 payment_date = to_timezone(payment.payment_date, tz) 159 if payment_date > payments_start and \ 160 payment_date < payments_end: 161 payments.append(payment) 162 else: 163 # Payment period not given 164 if p_states: 165 # Only paid tickets are considered 166 for student in students: 167 for payment in student.get('payments', {}).values(): 168 if payment.p_state in p_states: 169 payments.append(payment) 170 else: 171 # All tickets are considered 172 for student in students: 173 for payment in student.get('payments', {}).values(): 174 payments.append(payment) 137 paycat = kw.get('paycat') 138 for student in students: 139 for payment in student.get('payments', {}).values(): 140 if payments_start and payments_end: 141 if not payment.payment_date: 142 continue 143 payments_start = datetime.strptime(payments_start, date_format) 144 payments_end = datetime.strptime(payments_end, date_format) 145 tz = getUtility(IKofaUtils).tzinfo 146 payments_start = tz.localize(payments_start) 147 payments_end = tz.localize(payments_end) + timedelta(days=1) 148 payment_date = to_timezone(payment.payment_date, tz) 149 if payment_date < payments_start or payment_date > payments_end: 150 continue 151 if p_states and not payment.p_state in p_states: 152 continue 153 if paycat not in ('all', None) and payment.p_category != paycat: 154 continue 155 payments.append(payment) 175 156 return payments 176 157 … … 218 199 students.append(ticket.student) 219 200 return list(set(students)) 220 # Payments can be filtered by payment_date. The period boundaries 221 # are not keys of the catalog and must thus be removed from kw. 201 # Payments can be filtered by payment date and payment category. 202 # These parameters are not keys of the catalog and must thus be 203 # removed from kw. 222 204 try: 223 205 del kw['payments_start'] 224 206 del kw['payments_end'] 207 del kw['paycat'] 225 208 except KeyError: 226 209 pass 210 # Coursetickets can be filtered level and session. 211 # These parameters are not keys of the catalog and must thus be 212 # removed from kw. 227 213 try: 228 214 del kw['ct_level'] … … 433 419 by searching the students catalog. Then it exports student payment 434 420 tickets by iterating over the items of the student's ``payments`` 435 container. If the payment period is given only tickets, which were421 container. If the payment period is given, only tickets, which were 436 422 paid in payment period, are considered for export. 437 423 """ -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r14992 r15042 42 42 from waeup.kofa.app import University 43 43 from waeup.kofa.payments.interfaces import IPayer 44 from waeup.kofa.students.payments import StudentOnlinePayment 44 45 from waeup.kofa.students.student import Student 45 46 from waeup.kofa.students.studylevel import StudentStudyLevel … … 58 59 URL_LECTURER_LANDING = 'http://localhost/app/my_courses' 59 60 61 curr_year = datetime.now().year 60 62 61 63 def lookup_submit_value(name, value, browser): … … 3484 3486 return job_id 3485 3487 3488 def add_payment(self, student): 3489 # get a payment with all fields set 3490 payment = StudentOnlinePayment() 3491 payment.creation_date = datetime(2012, 12, 13) 3492 payment.p_id = 'my-id' 3493 payment.p_category = u'schoolfee' 3494 payment.p_state = 'paid' 3495 payment.ac = u'666' 3496 payment.p_item = u'p-item' 3497 payment.p_level = 100 3498 payment.p_session = curr_year - 6 3499 payment.payment_date = datetime(2012, 12, 13) 3500 payment.amount_auth = 12.12 3501 payment.r_amount_approved = 12.12 3502 payment.r_code = u'r-code' 3503 # XXX: there is no addPayment method to give predictable names 3504 self.payment = student['payments']['my-payment'] = payment 3505 return payment 3506 3486 3507 def test_datacenter_export(self): 3487 3508 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') … … 3518 3539 'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig ' 3519 3540 '- exported: bursary (2004, 100, ug_ft, None, None, None, ' 3520 '13/12/2012, 14/12/2012 ), job_id=%s'3541 '13/12/2012, 14/12/2012, all, all, all), job_id=%s' 3521 3542 % job_id in logcontent 3522 3543 ) … … 3572 3593 3573 3594 def test_faculties_export(self): 3595 self.add_payment(self.student) 3574 3596 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 3575 3597 facs_path = 'http://localhost/app/faculties' … … 3583 3605 self.browser.getControl(name="payments_start").value = '13/12/2012' 3584 3606 self.browser.getControl(name="payments_end").value = '14/12/2012' 3607 self.browser.getControl(name="paycat").value = ['schoolfee'] 3585 3608 self.browser.getControl("Create CSV file").click() 3586 3609 … … 3595 3618 'filename="WAeUP.Kofa_bursary_%s.csv' % job_id in 3596 3619 self.browser.headers['content-disposition']) 3620 self.assertTrue( 3621 '666,12.12,2012-12-13 00:00:00#,schoolfee,1,my-id,p-item,100,2012,' 3622 'paid,2012-12-13 00:00:00#,12.12,r-code,,K1000000,234,123,Anna,,' 3623 'Tester,created,2004,2004,,fac1,dep1,CERT1' in self.browser.contents) 3597 3624 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 3598 3625 job_id = self.app['datacenter'].running_exports[0][0] … … 3608 3635 'zope.mgr - students.browser.FacultiesExportJobContainerJobConfig ' 3609 3636 '- exported: bursary (2004, 100, ug_ft, None, None, None, ' 3610 '13/12/2012, 14/12/2012 ), job_id=%s'3637 '13/12/2012, 14/12/2012, all, all, schoolfee), job_id=%s' 3611 3638 % job_id in logcontent 3612 3639 ) … … 3669 3696 'zope.mgr - students.browser.FacultyExportJobContainerJobConfig ' 3670 3697 '- exported: students (2004, 100, ug_ft, fac1, None, None, ' 3671 '13/12/2012, 14/12/2012 ), job_id=%s'3698 '13/12/2012, 14/12/2012, all, all, all), job_id=%s' 3672 3699 % job_id in logcontent 3673 3700 ) … … 3721 3748 'zope.mgr - students.browser.DepartmentExportJobContainerJobConfig ' 3722 3749 '- exported: students (2004, 100, ug_ft, None, dep1, None, ' 3723 '13/12/2012, 14/12/2012 ), job_id=%s'3750 '13/12/2012, 14/12/2012, all, all, all), job_id=%s' 3724 3751 % job_id in logcontent 3725 3752 ) … … 3767 3794 self.assertTrue( 3768 3795 'zope.mgr - students.browser.CertificateExportJobContainerJobConfig ' 3769 '- exported: students (2004, 100, None, None, None, CERT1, None, None), ' 3796 '- exported: students ' 3797 '(2004, 100, None, None, None, CERT1, , , None, None, None), ' 3770 3798 'job_id=%s' 3771 3799 % job_id in logcontent
Note: See TracChangeset for help on using the changeset viewer.