[9465] | 1 | ## $Id: export.py 16426 2021-03-22 22:07:47Z 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 |
---|
[16425] | 21 | import sys |
---|
[9465] | 22 | from waeup.kofa.applicants.interfaces import IApplicantBaseData |
---|
[13981] | 23 | from waeup.kofa.utils.helpers import iface_names |
---|
[12082] | 24 | from kofacustom.nigeria.applicants.export import NigeriaApplicantExporter |
---|
[9465] | 25 | from kofacustom.nigeria.applicants.interfaces import INigeriaUGApplicant |
---|
[13877] | 26 | from waeup.fceokene.applicants.interfaces import ( |
---|
| 27 | ICustomUGApplicant, ITPURegistration) |
---|
[16426] | 28 | from waeup.fceokene.applicants.schools_pandemic import SCHOOLS |
---|
[9465] | 29 | |
---|
[12082] | 30 | class CustomApplicantExporter(NigeriaApplicantExporter): |
---|
[9465] | 31 | """Exporter for Nigeria Applicants. |
---|
| 32 | """ |
---|
| 33 | |
---|
| 34 | fields = tuple(sorted(set( |
---|
[13981] | 35 | iface_names(ICustomUGApplicant) + |
---|
| 36 | iface_names(INigeriaUGApplicant) + |
---|
| 37 | iface_names(IApplicantBaseData) + |
---|
| 38 | iface_names(ITPURegistration) |
---|
| 39 | ))) + ( |
---|
| 40 | 'password', 'state', 'history', 'container_code', 'application_number', |
---|
[14131] | 41 | 'display_fullname', 'application_date', |
---|
| 42 | 'school_name1', 'school_name2', 'school_name3') |
---|
| 43 | |
---|
| 44 | def mangle_value(self, value, name, context=None): |
---|
| 45 | """The mangler determines the codes of the atributes `course1`, |
---|
| 46 | `course2` and `course_admitted`. It furthermore prepares the |
---|
| 47 | history messages and adds a hash symbol at the end of the phone number |
---|
| 48 | to avoid annoying automatic number transformation by Excel or Calc. |
---|
| 49 | """ |
---|
| 50 | if name.startswith('school_name'): |
---|
[15112] | 51 | value = getattr(context, name.replace('_name', ''), None) |
---|
[14131] | 52 | if value: |
---|
[16420] | 53 | try: |
---|
| 54 | value = '%s - %s - %s' % ( |
---|
| 55 | SCHOOLS[value][0], SCHOOLS[value][1], SCHOOLS[value][2]) |
---|
| 56 | except: |
---|
[16426] | 57 | pass |
---|
[14131] | 58 | return super( |
---|
| 59 | CustomApplicantExporter, self).mangle_value( |
---|
| 60 | value, name, context=context) |
---|