1 | ## $Id: export.py 12084 2014-11-28 09:54:10Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2015 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 | import grok |
---|
21 | from datetime import datetime |
---|
22 | from waeup.uniben.students.interfaces import ( |
---|
23 | ICustomStudent, |
---|
24 | ICustomStudentStudyCourse, |
---|
25 | ICustomStudentStudyLevel, |
---|
26 | ICustomCourseTicket, |
---|
27 | ICustomStudentOnlinePayment, |
---|
28 | IMedicalHistory) |
---|
29 | from kofacustom.nigeria.students.export import ( |
---|
30 | NigeriaStudentExporter, |
---|
31 | NigeriaStudentStudyCourseExporter, |
---|
32 | NigeriaStudentStudyLevelExporter, |
---|
33 | NigeriaCourseTicketExporter, |
---|
34 | NigeriaStudentPaymentExporter, |
---|
35 | NigeriaDataForBursaryExporter, |
---|
36 | ) |
---|
37 | from waeup.kofa.students.export import ( |
---|
38 | SchoolFeePaymentsOverviewExporter, StudentExporterBase) |
---|
39 | from waeup.kofa.utils.helpers import iface_names |
---|
40 | |
---|
41 | class CustomStudentExporter(NigeriaStudentExporter): |
---|
42 | """Exporter for Students. |
---|
43 | """ |
---|
44 | |
---|
45 | fields = tuple(sorted(iface_names( |
---|
46 | ICustomStudent, omit=['loggerInfo']))) + ( |
---|
47 | 'password', 'state', 'history', 'certcode', 'is_postgrad', |
---|
48 | 'current_level', 'current_session') |
---|
49 | |
---|
50 | class CustomStudentStudyCourseExporter(NigeriaStudentStudyCourseExporter): |
---|
51 | """Exporter for StudentStudyCourses. |
---|
52 | """ |
---|
53 | |
---|
54 | fields = tuple( |
---|
55 | sorted(iface_names(ICustomStudentStudyCourse))) + ('student_id',) |
---|
56 | |
---|
57 | class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter): |
---|
58 | """Exporter for StudentStudyLevels. |
---|
59 | """ |
---|
60 | #: Fieldnames considered by this exporter |
---|
61 | fields = tuple(sorted(iface_names( |
---|
62 | ICustomStudentStudyLevel))) + ( |
---|
63 | 'student_id', 'number_of_tickets','certcode') |
---|
64 | |
---|
65 | class CustomCourseTicketExporter(NigeriaCourseTicketExporter): |
---|
66 | """Exporter for CourseTickets. |
---|
67 | """ |
---|
68 | |
---|
69 | fields = tuple(sorted(iface_names(ICustomCourseTicket) + |
---|
70 | ['level', 'code', 'level_session'])) + ('student_id', |
---|
71 | 'certcode', 'display_fullname') |
---|
72 | |
---|
73 | class CustomStudentPaymentExporter(NigeriaStudentPaymentExporter): |
---|
74 | """Exporter for OnlinePayment instances. |
---|
75 | """ |
---|
76 | |
---|
77 | fields = tuple( |
---|
78 | sorted(iface_names( |
---|
79 | ICustomStudentOnlinePayment, exclude_attribs=False, |
---|
80 | omit=['display_item']))) + ( |
---|
81 | 'student_id','state','current_session') |
---|
82 | |
---|
83 | class CustomDataForBursaryExporter(NigeriaDataForBursaryExporter): |
---|
84 | """ |
---|
85 | """ |
---|
86 | |
---|
87 | fields = tuple( |
---|
88 | sorted(iface_names( |
---|
89 | ICustomStudentOnlinePayment, exclude_attribs=False, |
---|
90 | omit=['display_item', 'certificate', 'student']))) + ( |
---|
91 | 'student_id','matric_number','reg_number', |
---|
92 | 'firstname', 'middlename', 'lastname', |
---|
93 | 'state','current_session', |
---|
94 | 'entry_session', 'entry_mode', |
---|
95 | 'faccode', 'depcode','certcode') |
---|
96 | |
---|
97 | class CustomSchoolFeePaymentsOverviewExporter(SchoolFeePaymentsOverviewExporter): |
---|
98 | |
---|
99 | curr_year = datetime.now().year |
---|
100 | year_range = range(curr_year - 14, curr_year + 1) # 3 more years in Uniben |
---|
101 | year_range_tuple = tuple([str(year) for year in year_range]) |
---|
102 | |
---|
103 | fields = ('student_id', 'matric_number', 'display_fullname', |
---|
104 | 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad', |
---|
105 | 'current_level', 'current_session', 'current_mode', |
---|
106 | 'entry_session', 'reg_number' |
---|
107 | ) + year_range_tuple |
---|
108 | |
---|
109 | class MedicalHistoryExporter(grok.GlobalUtility, StudentExporterBase): |
---|
110 | """ |
---|
111 | """ |
---|
112 | grok.name('medicalhistory') |
---|
113 | |
---|
114 | fields = tuple( |
---|
115 | sorted(iface_names( |
---|
116 | IMedicalHistory, exclude_attribs=False,))) + ( |
---|
117 | 'student_id','display_fullname', 'matric_number', 'faccode', |
---|
118 | 'depcode', 'state','current_session', 'current_level') |
---|
119 | title = 'Medical Questionnaire Data' |
---|
120 | |
---|
121 | def mangle_value(self, value, name, context=None): |
---|
122 | """The mangler determines the titles of faculty, department |
---|
123 | and certificate. It also computes the path of passport image file |
---|
124 | stored in the filesystem. |
---|
125 | """ |
---|
126 | if context is not None: |
---|
127 | student = context.student |
---|
128 | if name in ('student_id','display_fullname', |
---|
129 | 'matric_number', 'faccode', |
---|
130 | 'depcode', 'state','current_session', |
---|
131 | 'current_level') and student is not None: |
---|
132 | value = getattr(student, name, None) |
---|
133 | return super( |
---|
134 | MedicalHistoryExporter, self).mangle_value( |
---|
135 | value, name, context=context) |
---|