Ignore:
Timestamp:
8 Nov 2012, 13:25:38 (12 years ago)
Author:
Henrik Bettermann
Message:

Add StudentPaymentsOverviewExporter?.

File:
1 edited

Legend:

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

    r9427 r9574  
    1919"""
    2020import grok
     21from datetime import datetime
    2122from zope.catalog.interfaces import ICatalog
    2223from zope.component import queryUtility
     
    320321    def export_student(self, student, filepath=None):
    321322        return self.export(get_bedtickets([student]), filepath)
     323
     324class StudentPaymentsOverviewExporter(StudentsExporter):
     325    """Exporter for students with payment overview.
     326    """
     327    grok.name('paymentsoverview')
     328
     329    curr_year = datetime.now().year
     330    year_range = range(curr_year - 9, curr_year + 1)
     331    year_range_tuple = tuple([str(year) for year in year_range])
     332
     333    #: Fieldnames considered by this exporter
     334    fields = ('student_id', ) + (
     335        'state', 'certcode', 'faccode', 'depcode', 'is_postgrad',
     336        'current_level', 'current_session',
     337        ) + year_range_tuple
     338
     339    #: The title under which this exporter will be displayed
     340    title = _(u'Student Payments Overview')
     341
     342    def mangle_value(self, value, name, context=None):
     343        if name in self.year_range_tuple and context is not None:
     344            value = ''
     345            for ticket in context['payments'].values():
     346                if ticket.p_state == 'paid' and \
     347                    ticket.p_category == 'schoolfee' and \
     348                    ticket.p_session == int(name):
     349                    value = ticket.amount_auth
     350                    break
     351        return super(
     352            StudentsExporter, self).mangle_value(
     353            value, name, context=context)
Note: See TracChangeset for help on using the changeset viewer.