source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/export.py @ 15668

Last change on this file since 15668 was 15112, checked in by Henrik Bettermann, 6 years ago

Fix bug.

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1## $Id: export.py 15112 2018-08-21 05:12:51Z henrik $
2##
3## Copyright (C) 2012 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
21from waeup.kofa.applicants.interfaces import IApplicantBaseData
22from waeup.kofa.utils.helpers import iface_names
23from kofacustom.nigeria.applicants.export import NigeriaApplicantExporter
24from kofacustom.nigeria.applicants.interfaces import INigeriaUGApplicant
25from waeup.fceokene.applicants.interfaces import (
26    ICustomUGApplicant, ITPURegistration)
27from waeup.fceokene.applicants.schools import SCHOOLS
28
29class CustomApplicantExporter(NigeriaApplicantExporter):
30    """Exporter for Nigeria Applicants.
31    """
32
33    fields = tuple(sorted(set(
34        iface_names(ICustomUGApplicant) +
35        iface_names(INigeriaUGApplicant) +
36        iface_names(IApplicantBaseData) +
37        iface_names(ITPURegistration)
38        ))) + (
39        'password', 'state', 'history', 'container_code', 'application_number',
40        'display_fullname', 'application_date',
41        'school_name1', 'school_name2', 'school_name3')
42
43    def mangle_value(self, value, name, context=None):
44        """The mangler determines the codes of the atributes `course1`,
45        `course2` and `course_admitted`. It furthermore prepares the
46        history messages and adds a hash symbol at the end of the phone number
47        to avoid annoying automatic number transformation by Excel or Calc.
48        """
49        if name.startswith('school_name'):
50            value = getattr(context, name.replace('_name', ''), None)
51            if value:
52                value = '%s - %s - %s' % (
53                    SCHOOLS[value][0], SCHOOLS[value][1], SCHOOLS[value][2])
54        return super(
55            CustomApplicantExporter, self).mangle_value(
56            value, name, context=context)
Note: See TracBrowser for help on using the repository browser.