1 | ## $Id: export.py 15400 2019-05-03 06:18:26Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2011 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 student related stuff. |
---|
19 | """ |
---|
20 | from waeup.kofa.utils.batching import ExporterBase |
---|
21 | from kofacustom.dspg.students.interfaces import ( |
---|
22 | ICustomStudent, |
---|
23 | ICustomStudentStudyCourse, |
---|
24 | ICustomStudentStudyLevel, |
---|
25 | ICustomCourseTicket, |
---|
26 | ICustomStudentOnlinePayment) |
---|
27 | from kofacustom.nigeria.students.export import ( |
---|
28 | NigeriaStudentExporter, |
---|
29 | NigeriaStudentStudyCourseExporter, |
---|
30 | NigeriaStudentStudyLevelExporter, |
---|
31 | NigeriaCourseTicketExporter, |
---|
32 | NigeriaStudentPaymentExporter) |
---|
33 | from waeup.kofa.utils.helpers import iface_names |
---|
34 | |
---|
35 | class CustomStudentExporter(NigeriaStudentExporter): |
---|
36 | """Exporter for Students. |
---|
37 | """ |
---|
38 | |
---|
39 | fields = tuple(sorted(iface_names( |
---|
40 | ICustomStudent, omit=['loggerInfo']))) + ( |
---|
41 | 'password', 'state', 'history', 'certcode', 'is_postgrad', |
---|
42 | 'current_level', 'current_session', 'entry_session') |
---|
43 | |
---|
44 | class CustomStudentStudyCourseExporter(NigeriaStudentStudyCourseExporter): |
---|
45 | """Exporter for StudentStudyCourses. |
---|
46 | """ |
---|
47 | |
---|
48 | fields = tuple( |
---|
49 | sorted(iface_names(ICustomStudentStudyCourse))) + ( |
---|
50 | 'student_id', 'current_mode') |
---|
51 | |
---|
52 | def mangle_value(self, value, name, context=None): |
---|
53 | if name == 'certificate' and value is not None: |
---|
54 | value = value.code |
---|
55 | if name in ('student_id', 'current_mode') and context is not None: |
---|
56 | student = context.student |
---|
57 | value = getattr(student, name, None) |
---|
58 | return ExporterBase().mangle_value(value, name, context=context) |
---|
59 | |
---|
60 | class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter): |
---|
61 | """Exporter for StudentStudyLevels. |
---|
62 | """ |
---|
63 | #: Fieldnames considered by this exporter |
---|
64 | fields = tuple(sorted(iface_names( |
---|
65 | ICustomStudentStudyLevel))) + ( |
---|
66 | 'student_id', 'number_of_tickets','certcode') |
---|
67 | |
---|
68 | class CustomCourseTicketExporter(NigeriaCourseTicketExporter): |
---|
69 | """Exporter for CourseTickets. |
---|
70 | """ |
---|
71 | |
---|
72 | fields = tuple(sorted(iface_names(ICustomCourseTicket) + |
---|
73 | ['level', 'code', 'level_session'])) + ('student_id', |
---|
74 | 'certcode', 'display_fullname') |
---|
75 | |
---|
76 | class CustomStudentPaymentExporter(NigeriaStudentPaymentExporter): |
---|
77 | """Exporter for OnlinePayment instances. |
---|
78 | """ |
---|
79 | |
---|
80 | fields = tuple( |
---|
81 | sorted(iface_names( |
---|
82 | ICustomStudentOnlinePayment, exclude_attribs=False, |
---|
83 | omit=['display_item']))) + ( |
---|
84 | 'student_id','state','current_session') |
---|
85 | |
---|