Ignore:
Timestamp:
27 May 2013, 07:14:13 (12 years ago)
Author:
Henrik Bettermann
Message:

Add exporter fur bursary data.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r10232 r10233  
    3737        'studentstudylevels', 'coursetickets',
    3838        'studentpayments', 'bedtickets', 'paymentsoverview',
    39         'studylevelsoverview', 'combocard')
     39        'studylevelsoverview', 'combocard', 'bursary')
    4040
    4141def get_students(site, stud_filter=StudentsQuery()):
     
    314314            value, name, context=context)
    315315
     316class DataForBursaryExporter(StudentPaymentsExporter):
     317    """Exporter for OnlinePayment instances.
     318    """
     319    grok.name('bursary')
     320
     321    #: Fieldnames considered by this exporter
     322    fields = tuple(
     323        sorted(iface_names(
     324            IStudentOnlinePayment, exclude_attribs=False,
     325            omit=['display_item']))) + (
     326            'student_id','matric_number','state','current_session',
     327            'faccode', 'depcode', 'display_fullname')
     328
     329    #: The title under which this exporter will be displayed
     330    title = _(u'Payment Data for Bursary')
     331
     332    def mangle_value(self, value, name, context=None):
     333        """Treat location values special.
     334        """
     335        if context is not None:
     336            student = context.student
     337            if name in ['student_id','matric_number',
     338                        'state','current_session',
     339                        'faccode','depcode',
     340                        'display_fullname'] and student is not None:
     341                value = getattr(student, name, None)
     342        return super(
     343            StudentPaymentsExporter, self).mangle_value(
     344            value, name, context=context)
     345
    316346class BedTicketsExporter(grok.GlobalUtility, StudentExporterBase):
    317347    """Exporter for BedTicket instances.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r10232 r10233  
    1313    CourseTicketExporter, StudentPaymentsExporter, BedTicketsExporter,
    1414    StudentPaymentsOverviewExporter, StudentStudyLevelsOverviewExporter,
    15     ComboCardDataExporter,
     15    ComboCardDataExporter, DataForBursaryExporter,
    1616    get_students,)
    1717from waeup.kofa.students.accommodation import BedTicket
     
    717717        return
    718718
     719class BursaryDataExporterTest(StudentImportExportSetup):
     720
     721    layer = FunctionalLayer
     722
     723    def setUp(self):
     724        super(BursaryDataExporterTest, self).setUp()
     725        self.setup_for_export()
     726        return
     727
     728    def test_export_all(self):
     729        # we can really export all payments
     730        # set values we can expect in export file
     731        self.setup_student(self.student)
     732        exporter = DataForBursaryExporter()
     733        exporter.export_all(self.app, self.outfile)
     734        result = open(self.outfile, 'rb').read()
     735        self.assertEqual(
     736            result,
     737            'ac,amount_auth,creation_date,p_category,p_current,p_id,p_item,'
     738            'p_level,p_session,p_state,payment_date,r_amount_approved,'
     739            'r_code,r_desc,student_id,matric_number,state,current_session,'
     740            'faccode,depcode,display_fullname\r\n'
     741
     742            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,p-item,100,2012,'
     743            'unpaid,2012-04-01 14:12:01,12.12,r-code,,A111111,'
     744            '234,created,2012,NA,NA,Anna M. Tester\r\n'
     745            )
     746        return
     747
    719748class BedTicketsExporterTest(StudentImportExportSetup):
    720749
Note: See TracChangeset for help on using the changeset viewer.