source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants/export.py @ 15842

Last change on this file since 15842 was 15516, checked in by Henrik Bettermann, 5 years ago

Hmmm

  • Property svn:keywords set to Id
File size: 2.8 KB
RevLine 
[11543]1## $Id: export.py 15516 2019-07-24 20:42:18Z henrik $
2##
3## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""Exporters for applicant-related stuff.
19"""
20import grok
[15513]21from waeup.kofa.applicants.interfaces import (
22    IApplicantBaseData, IApplicantOnlinePayment)
[13983]23from waeup.kofa.utils.helpers import iface_names
[15513]24from waeup.kofa.applicants.export import ApplicantPaymentExporter
[12084]25from kofacustom.nigeria.applicants.export import NigeriaApplicantExporter
[11543]26from kofacustom.nigeria.applicants.interfaces import (
27    INigeriaUGApplicant, INigeriaPGApplicant)
[14716]28from kofacustom.dspg.applicants.interfaces import (
[15186]29    ICustomUGApplicant, ICustomPGApplicant, ICustomSpecialApplicant)
[11543]30
[12084]31class CustomApplicantExporter(NigeriaApplicantExporter):
[11543]32    """Exporter for Custom Applicants.
33    """
34
35    fields = tuple(sorted(set(
[13983]36        iface_names(ICustomUGApplicant) +
37        iface_names(ICustomPGApplicant) +
[15186]38        iface_names(ICustomSpecialApplicant) +
[13983]39        iface_names(INigeriaUGApplicant) +
40        iface_names(INigeriaPGApplicant) +
41        iface_names(IApplicantBaseData)
42        ))) + (
43        'password', 'state', 'history', 'container_code', 'application_number',
44        'display_fullname', 'application_date')
[15513]45
46class CustomApplicantPaymentExporter(ApplicantPaymentExporter):
47    """
48    """
49    fields = tuple(sorted(iface_names(
50        IApplicantOnlinePayment,
51        exclude_attribs=False,
52        omit=['display_item']))) + (
53              'applicant_id',
54              'reg_number',
55              'display_fullname',
56              'course1',
57              'course2')
58
59    def mangle_value(self, value, name, context=None):
60        """
61        """
62        if name in ('applicant_id', 'reg_number',
[15514]63            'display_fullname') and context is not None:
[15513]64            applicant = context.__parent__
65            value = getattr(applicant, name, None)
[15514]66        if name in ('course1', 'course2') and context is not None:
67            applicant = context.__parent__
[15516]68            value = getattr(getattr(applicant, name, None), 'code', None)
[15513]69        return super(
70            CustomApplicantPaymentExporter, self).mangle_value(
71            value, name, context=context)
Note: See TracBrowser for help on using the repository browser.