[9465] | 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 | """ |
---|
| 20 | import grok |
---|
| 21 | from waeup.kofa.applicants.interfaces import IApplicantBaseData |
---|
[13981] | 22 | from waeup.kofa.utils.helpers import iface_names |
---|
[12082] | 23 | from kofacustom.nigeria.applicants.export import NigeriaApplicantExporter |
---|
[9465] | 24 | from kofacustom.nigeria.applicants.interfaces import INigeriaUGApplicant |
---|
[13877] | 25 | from waeup.fceokene.applicants.interfaces import ( |
---|
| 26 | ICustomUGApplicant, ITPURegistration) |
---|
[14131] | 27 | from waeup.fceokene.applicants.schools import SCHOOLS |
---|
[9465] | 28 | |
---|
[12082] | 29 | class CustomApplicantExporter(NigeriaApplicantExporter): |
---|
[9465] | 30 | """Exporter for Nigeria Applicants. |
---|
| 31 | """ |
---|
| 32 | |
---|
| 33 | fields = tuple(sorted(set( |
---|
[13981] | 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', |
---|
[14131] | 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'): |
---|
[15112] | 50 | value = getattr(context, name.replace('_name', ''), None) |
---|
[14131] | 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) |
---|