Ignore:
Timestamp:
27 Nov 2024, 02:19:52 (4 weeks ago)
Author:
Henrik Bettermann
Message:

Add exporter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/export.py

    r17857 r17965  
    2727    INigeriaUGApplicant, INigeriaPGApplicant, IBankAccount)
    2828from waeup.uniben.applicants.interfaces import (
    29     IUnibenRegistration, ITranscriptApplicant, IFrenchApplicant)
     29    IUnibenRegistration, ITranscriptApplicant,
     30    IFrenchApplicant, IAfrimalApplicant)
    3031
    3132class CustomApplicantExporter(NigeriaApplicantExporter):
     
    4041        iface_names(ITranscriptApplicant) +
    4142        iface_names(IFrenchApplicant) +
     43        iface_names(IAfrimalApplicant) +
    4244        iface_names(IBankAccount)
    4345        ))) + (
     
    99101        return self.close_outfile(filepath, outfile)
    100102
     103class AfrimalApplicantExporter(CustomApplicantExporter):
     104    """
     105    """
     106
     107    grok.name('afrimal_applicants')
     108    title = 'AFRIMAL Applicants'
     109
     110    fields = tuple(sorted(set(
     111        iface_names(IAfrimalApplicant)
     112        ))) + (
     113        'password', 'state', 'history', 'container_code', 'application_number',
     114        'display_fullname', 'application_date')
     115
     116    def export(self, applicants, filepath=None):
     117        """Exports afrimal applicants only
     118        """
     119        writer, outfile = self.get_csv_writer(filepath)
     120        for applicant in applicants:
     121            if applicant.__parent__.code.startswith('afrimal'):
     122                self.write_item(applicant, writer)
     123        return self.close_outfile(filepath, outfile)
     124
    101125class TranscriptApplicantExporter(CustomApplicantExporter):
    102126    """
Note: See TracChangeset for help on using the changeset viewer.