1 | ## $Id: export.py 16872 2022-03-09 20:53:31Z 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 | import sys |
---|
22 | from waeup.kofa.applicants.interfaces import IApplicantBaseData |
---|
23 | from waeup.kofa.utils.helpers import iface_names |
---|
24 | from kofacustom.nigeria.applicants.export import NigeriaApplicantExporter |
---|
25 | from kofacustom.nigeria.applicants.interfaces import INigeriaUGApplicant |
---|
26 | from waeup.fceokene.applicants.interfaces import ( |
---|
27 | ICustomUGApplicant, ITPURegistration) |
---|
28 | from waeup.fceokene.applicants.schools_pandemic import SCHOOLS |
---|
29 | |
---|
30 | class CustomApplicantExporter(NigeriaApplicantExporter): |
---|
31 | """Exporter for Nigeria Applicants. |
---|
32 | """ |
---|
33 | |
---|
34 | fields = tuple(sorted(set( |
---|
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', |
---|
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'): |
---|
51 | value = getattr(context, name.replace('_name', ''), None) |
---|
52 | if value: |
---|
53 | try: |
---|
54 | value = '%s - %s - %s' % ( |
---|
55 | SCHOOLS[value][0], SCHOOLS[value][1], SCHOOLS[value][2]) |
---|
56 | except: |
---|
57 | pass |
---|
58 | if name == 'subj_comb' and value is not None: |
---|
59 | value = value.code |
---|
60 | return super( |
---|
61 | CustomApplicantExporter, self).mangle_value( |
---|
62 | value, name, context=context) |
---|