Ignore:
Timestamp:
4 Feb 2020, 10:06:02 (5 years ago)
Author:
Henrik Bettermann
Message:
 
Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportconfig.pt

    r15920 r15979  
    155155          document.getElementById('exporter').value == 'studentpayments' ||
    156156          document.getElementById('exporter').value == 'accommodationpayments' ||
     157          document.getElementById('exporter').value == 'trimmedpayments' ||
    157158          document.getElementById('exporter').value == 'unpaidpayments') {
    158159          document.getElementById('payment_dates').style.display = 'block';
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r15966 r15979  
    508508            value, name, context=context)
    509509
     510class StudentTrimmedPaymentExporter(grok.GlobalUtility, StudentExporterBase):
     511    """The Student Trimmed Payment Exporter is a slightly customized version
     512    of the StudentPaymentExporter requested by Uniben.
     513    """
     514    grok.name('trimmedpayments')
     515
     516    fields = tuple(
     517        sorted(iface_names(
     518            IStudentOnlinePayment, exclude_attribs=False,
     519            omit=['display_item', 'certificate', 'student', 'ac']))) + (
     520            'student_id','faccode', 'depcode', 'state','current_session')
     521    title = _(u'Student Payments (Sorted Data)')
     522
     523    def filter_func(self, x, **kw):
     524        payments = get_payments(x, **kw)
     525        return sorted([payment for payment in payments],
     526            key=lambda payment: payment.category + str(payment.student.faccode)
     527                + str(payment.student.depcode) + str(payment.p_item))
     528
     529    def mangle_value(self, value, name, context=None):
     530        """The mangler determines the student's id, registration
     531        state and current session.
     532        """
     533        if context is not None:
     534            student = context.student
     535            if name in ['student_id','state', 'faccode', 'depcode',
     536                        'current_session'] and student is not None:
     537                value = getattr(student, name, None)
     538        return super(
     539            StudentTrimmedPaymentExporter, self).mangle_value(
     540            value, name, context=context)
     541
    510542class DataForLecturerExporter(grok.GlobalUtility, StudentExporterBase):
    511543    """The Data for Lecturer Exporter searches for students in the course
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r15966 r15979  
    3939    TranscriptDataExporter,
    4040    TrimmedDataExporter,
     41    StudentTrimmedPaymentExporter,
    4142    get_students,)
    4243from waeup.kofa.students.accommodation import BedTicket
     
    10891090            )
    10901091        return
     1092
     1093class StudentTrimmedPaymentExporterTest(StudentImportExportSetup):
     1094
     1095    layer = FunctionalLayer
     1096
     1097    def setUp(self):
     1098        super(StudentTrimmedPaymentExporterTest, self).setUp()
     1099        self.setup_for_export()
     1100        return
     1101
     1102    def test_ifaces(self):
     1103        # make sure we fullfill interface contracts
     1104        obj = StudentTrimmedPaymentExporter()
     1105        verifyObject(ICSVStudentExporter, obj)
     1106        verifyClass(ICSVStudentExporter, StudentTrimmedPaymentExporter)
     1107        return
     1108
     1109    def test_get_as_utility(self):
     1110        # we can get a payments exporter as utility
     1111        result = queryUtility(ICSVExporter, name="trimmedpayments")
     1112        self.assertTrue(result is not None)
     1113        return
     1114
     1115    def test_export_all(self):
     1116        # we can really export all payments
     1117        # set values we can expect in export file
     1118        self.setup_student(self.student)
     1119        exporter = StudentTrimmedPaymentExporter()
     1120        exporter.export_all(self.app, self.outfile)
     1121        result = open(self.outfile, 'rb').read()
     1122        self.assertEqual(
     1123            result,
     1124            'amount_auth,creation_date,p_category,p_combi,p_current,'
     1125            'p_id,p_item,p_level,p_session,p_state,payment_date,'
     1126            'r_amount_approved,r_code,r_desc,student_id,faccode,'
     1127            'depcode,state,current_session\r\n'
     1128
     1129            '12.12,%s-04-01 13:12:01#,schoolfee,[],1,my-id,p-item,'
     1130            '100,%s,paid,%s-04-01 14:12:01#,12.12,r-code,,'
     1131            'A111111,NA,NA,created,2012\r\n'
     1132            % (curr_year-6, curr_year-6, curr_year-6)
     1133            )
     1134        return
     1135
    10911136
    10921137class UnpaidPaymentsExporterTest(StudentImportExportSetup):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r15966 r15979  
    11661166            'bursary',
    11671167            'accommodationpayments',
    1168             'transcriptdata')
     1168            'transcriptdata',
     1169            #'trimmedpayments',
     1170            )
    11691171
    11701172    #: A tuple containing all exporter names needed for backing
Note: See TracChangeset for help on using the changeset viewer.