Changeset 12971 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 21 May 2015, 07:38:15 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportconfig.pt
r11730 r12971 74 74 function test() { 75 75 if (document.getElementById('exporter').value == 'bursary' || 76 document.getElementById('exporter').value == 'studentpayments') { 76 document.getElementById('exporter').value == 'studentpayments' || 77 document.getElementById('exporter').value == 'studentunpaidpayments') { 77 78 document.getElementById('payment_dates').style.display = 'block'; 78 79 } else { -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportconfig_certificate.pt
r11730 r12971 64 64 function test() { 65 65 if (document.getElementById('exporter').value == 'bursary' || 66 document.getElementById('exporter').value == 'studentpayments') { 66 document.getElementById('exporter').value == 'studentpayments' || 67 document.getElementById('exporter').value == 'studentunpaidpayments') { 67 68 document.getElementById('payment_dates').style.display = 'block'; 68 69 } else { -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r12873 r12971 86 86 return tickets 87 87 88 def get_payments(students, p aid=False, **kw):88 def get_payments(students, p_state=None, **kw): 89 89 """Get all payments of `students` within given payment_date period. 90 90 """ … … 100 100 payments_start = tz.localize(payments_start) 101 101 payments_end = tz.localize(payments_end) 102 if p aid:103 # Only paid tickets in payment period are considered102 if p_state: 103 # Only paid or unpaid tickets in payment period are considered 104 104 for student in students: 105 105 for payment in student.get('payments', {}).values(): 106 if payment.payment_date and payment.p_state == 'paid':106 if payment.payment_date and payment.p_state == p_state: 107 107 payment_date = to_timezone(payment.payment_date, tz) 108 108 if payment_date > payments_start and \ … … 120 120 else: 121 121 # Payment period not given 122 if p aid:122 if p_state: 123 123 # Only paid tickets are considered 124 124 for student in students: 125 125 for payment in student.get('payments', {}).values(): 126 if payment.p_state == 'paid':126 if payment.p_state == p_state: 127 127 payments.append(payment) 128 128 else: … … 382 382 value, name, context=context) 383 383 384 class StudentUnpaidPaymentExporter(StudentPaymentExporter): 385 """The Student Unpaid Payment Exporter works just like the 386 Student Payments Exporter but it exports only unpaid tickets. 387 This exporter is designed for finding and finally purging outdated 388 payment ticket. 389 """ 390 grok.name('studentunpaidpayments') 391 392 title = _(u'Student Unpaid Payments') 393 394 def filter_func(self, x, **kw): 395 return get_payments(x, p_state='unpaid', **kw) 396 384 397 class DataForBursaryExporter(StudentPaymentExporter): 385 398 """The DataForBursary Exporter works just like the Student Payments Exporter … … 392 405 393 406 def filter_func(self, x, **kw): 394 return get_payments(x, p aid=True, **kw)407 return get_payments(x, p_state='paid', **kw) 395 408 396 409 fields = tuple( -
main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
r12104 r12971 421 421 """ 422 422 423 STUDENT_ EXPORTER_NAMES = getUtility(424 IStudentsUtils).STUDENT_ EXPORTER_NAMES425 426 for name in STUDENT_ EXPORTER_NAMES:423 STUDENT_BACKUP_EXPORTER_NAMES = getUtility( 424 IStudentsUtils).STUDENT_BACKUP_EXPORTER_NAMES 425 426 for name in STUDENT_BACKUP_EXPORTER_NAMES: 427 427 exporter = getUtility(ICSVStudentExporter, name=name) 428 428 csv_data = exporter.export_student(student) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r12865 r12971 32 32 StudentPaymentsOverviewExporter, StudentStudyLevelsOverviewExporter, 33 33 ComboCardDataExporter, DataForBursaryExporter, 34 StudentUnpaidPaymentExporter, 34 35 get_students,) 35 36 from waeup.kofa.students.accommodation import BedTicket … … 895 896 result = open(self.outfile, 'rb').read() 896 897 898 return 899 900 class StudentUnpaidPaymentExporterTest(StudentImportExportSetup): 901 902 layer = FunctionalLayer 903 904 def setUp(self): 905 super(StudentUnpaidPaymentExporterTest, self).setUp() 906 self.setup_for_export() 907 return 908 909 def test_export_all(self): 910 # we can really export all payments 911 # set values we can expect in export file 912 self.setup_student(self.student) 913 exporter = StudentUnpaidPaymentExporter() 914 exporter.export_all(self.app, self.outfile) 915 result = open(self.outfile, 'rb').read() 916 # No unpaid ticket exists 917 self.assertEqual( 918 result, 919 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 920 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 921 'r_code,r_desc,student_id,state,current_session\r\n' 922 ) 923 # Make ticket unpaid 924 self.payment.p_state = 'unpaid' 925 exporter.export_all(self.app, self.outfile) 926 result = open(self.outfile, 'rb').read() 927 self.assertEqual( 928 result, 929 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 930 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 931 'r_code,r_desc,student_id,state,current_session\r\n' 932 933 '666,12.12,2012-04-01 13:12:01#,schoolfee,1,my-id,' 934 'p-item,100,2012,unpaid,2012-04-01 14:12:01#,12.12,' 935 'r-code,,A111111,created,2012\r\n' 936 ) 897 937 return 898 938 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py
r12104 r12971 182 182 183 183 # The student data were put into CSV files 184 STUDENT_ EXPORTER_NAMES = getUtility(185 IStudentsUtils).STUDENT_ EXPORTER_NAMES186 187 for name in STUDENT_ EXPORTER_NAMES:184 STUDENT_BACKUP_EXPORTER_NAMES = getUtility( 185 IStudentsUtils).STUDENT_BACKUP_EXPORTER_NAMES 186 187 for name in STUDENT_BACKUP_EXPORTER_NAMES: 188 188 csv_path = os.path.join(del_dir, '%s.csv' % name) 189 189 self.assertTrue(os.path.isfile(csv_path)) -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r12902 r12971 954 954 STUDENT_EXPORTER_NAMES = ('students', 'studentstudycourses', 955 955 'studentstudylevels', 'coursetickets', 956 'studentpayments', 'bedtickets', 'paymentsoverview', 956 'studentpayments', 'studentunpaidpayments', 957 'bedtickets', 'paymentsoverview', 957 958 'studylevelsoverview', 'combocard', 'bursary') 959 960 #: A tuple containing all exporter names needed for backing 961 #: up student data 962 STUDENT_BACKUP_EXPORTER_NAMES = ('students', 'studentstudycourses', 963 'studentstudylevels', 'coursetickets', 964 'studentpayments', 'bedtickets') 958 965 959 966 #: A prefix used when generating new student ids. Each student id will
Note: See TracChangeset for help on using the changeset viewer.