[12856] | 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 | """ |
---|
[16390] | 20 | import grok |
---|
[15025] | 21 | from datetime import datetime |
---|
[12856] | 22 | from waeup.uniben.students.interfaces import ( |
---|
| 23 | ICustomStudent, |
---|
| 24 | ICustomStudentStudyCourse, |
---|
| 25 | ICustomStudentStudyLevel, |
---|
| 26 | ICustomCourseTicket, |
---|
[16390] | 27 | ICustomStudentOnlinePayment, |
---|
| 28 | IMedicalHistory) |
---|
[12856] | 29 | from kofacustom.nigeria.students.export import ( |
---|
| 30 | NigeriaStudentExporter, |
---|
| 31 | NigeriaStudentStudyCourseExporter, |
---|
| 32 | NigeriaStudentStudyLevelExporter, |
---|
| 33 | NigeriaCourseTicketExporter, |
---|
[14856] | 34 | NigeriaStudentPaymentExporter, |
---|
[15025] | 35 | NigeriaDataForBursaryExporter, |
---|
[16498] | 36 | NigeriaTrimmedDataExporter, |
---|
[15025] | 37 | ) |
---|
[16390] | 38 | from waeup.kofa.students.export import ( |
---|
| 39 | SchoolFeePaymentsOverviewExporter, StudentExporterBase) |
---|
[12856] | 40 | from waeup.kofa.utils.helpers import iface_names |
---|
| 41 | |
---|
| 42 | class CustomStudentExporter(NigeriaStudentExporter): |
---|
| 43 | """Exporter for Students. |
---|
| 44 | """ |
---|
| 45 | |
---|
| 46 | fields = tuple(sorted(iface_names( |
---|
| 47 | ICustomStudent, omit=['loggerInfo']))) + ( |
---|
| 48 | 'password', 'state', 'history', 'certcode', 'is_postgrad', |
---|
| 49 | 'current_level', 'current_session') |
---|
| 50 | |
---|
[16498] | 51 | class CustomTrimmedDataExporter(NigeriaTrimmedDataExporter): |
---|
| 52 | """The Student Trimmed Data Exporter first filters the set of students |
---|
| 53 | by searching the students catalog. Then it exports a trimmed data set |
---|
| 54 | of this set of students. |
---|
| 55 | """ |
---|
| 56 | fields = ( |
---|
| 57 | 'student_id', |
---|
| 58 | 'matric_number', |
---|
| 59 | 'reg_number', |
---|
| 60 | 'firstname', |
---|
| 61 | 'middlename', |
---|
| 62 | 'lastname', |
---|
| 63 | 'sex', |
---|
| 64 | 'email', |
---|
| 65 | 'email2', |
---|
| 66 | 'phone', |
---|
[17776] | 67 | 'perm_address', |
---|
[16498] | 68 | 'nationality', |
---|
| 69 | 'date_of_birth', |
---|
| 70 | 'state', |
---|
| 71 | 'current_mode', |
---|
| 72 | 'certcode', |
---|
| 73 | 'faccode', |
---|
| 74 | 'depcode', |
---|
| 75 | 'current_level', |
---|
| 76 | 'current_session', |
---|
| 77 | 'current_verdict', |
---|
| 78 | 'entry_session', |
---|
| 79 | 'lg_state', |
---|
[17624] | 80 | 'lg_area', |
---|
| 81 | 'flash_notice') |
---|
[16498] | 82 | |
---|
[12856] | 83 | class CustomStudentStudyCourseExporter(NigeriaStudentStudyCourseExporter): |
---|
| 84 | """Exporter for StudentStudyCourses. |
---|
| 85 | """ |
---|
| 86 | |
---|
| 87 | fields = tuple( |
---|
[16837] | 88 | sorted(iface_names(ICustomStudentStudyCourse))) + ( |
---|
| 89 | 'student_id', 'previous') |
---|
[12856] | 90 | |
---|
| 91 | class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter): |
---|
| 92 | """Exporter for StudentStudyLevels. |
---|
| 93 | """ |
---|
| 94 | #: Fieldnames considered by this exporter |
---|
| 95 | fields = tuple(sorted(iface_names( |
---|
[12879] | 96 | ICustomStudentStudyLevel))) + ( |
---|
[16837] | 97 | 'student_id', 'number_of_tickets','certcode', 'previous') |
---|
[12856] | 98 | |
---|
| 99 | class CustomCourseTicketExporter(NigeriaCourseTicketExporter): |
---|
| 100 | """Exporter for CourseTickets. |
---|
| 101 | """ |
---|
| 102 | |
---|
| 103 | fields = tuple(sorted(iface_names(ICustomCourseTicket) + |
---|
| 104 | ['level', 'code', 'level_session'])) + ('student_id', |
---|
[17558] | 105 | 'certcode', 'display_fullname', 'previous', 'matric_number') |
---|
[12856] | 106 | |
---|
[12879] | 107 | class CustomStudentPaymentExporter(NigeriaStudentPaymentExporter): |
---|
[12856] | 108 | """Exporter for OnlinePayment instances. |
---|
| 109 | """ |
---|
| 110 | |
---|
| 111 | fields = tuple( |
---|
| 112 | sorted(iface_names( |
---|
| 113 | ICustomStudentOnlinePayment, exclude_attribs=False, |
---|
[13621] | 114 | omit=['display_item']))) + ( |
---|
[12856] | 115 | 'student_id','state','current_session') |
---|
| 116 | |
---|
[14856] | 117 | class CustomDataForBursaryExporter(NigeriaDataForBursaryExporter): |
---|
| 118 | """ |
---|
| 119 | """ |
---|
| 120 | |
---|
| 121 | fields = tuple( |
---|
| 122 | sorted(iface_names( |
---|
| 123 | ICustomStudentOnlinePayment, exclude_attribs=False, |
---|
| 124 | omit=['display_item', 'certificate', 'student']))) + ( |
---|
| 125 | 'student_id','matric_number','reg_number', |
---|
| 126 | 'firstname', 'middlename', 'lastname', |
---|
| 127 | 'state','current_session', |
---|
| 128 | 'entry_session', 'entry_mode', |
---|
| 129 | 'faccode', 'depcode','certcode') |
---|
[15025] | 130 | |
---|
[15048] | 131 | class CustomSchoolFeePaymentsOverviewExporter(SchoolFeePaymentsOverviewExporter): |
---|
[15025] | 132 | |
---|
| 133 | curr_year = datetime.now().year |
---|
[15044] | 134 | year_range = range(curr_year - 14, curr_year + 1) # 3 more years in Uniben |
---|
[15025] | 135 | year_range_tuple = tuple([str(year) for year in year_range]) |
---|
| 136 | |
---|
[16476] | 137 | fields = ('student_id', 'matric_number', 'firstname', 'middlename', |
---|
| 138 | 'lastname', 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad', |
---|
[15025] | 139 | 'current_level', 'current_session', 'current_mode', |
---|
[16498] | 140 | 'entry_session', 'reg_number', 'email2', 'sex' |
---|
[15025] | 141 | ) + year_range_tuple |
---|
[16390] | 142 | |
---|
| 143 | class MedicalHistoryExporter(grok.GlobalUtility, StudentExporterBase): |
---|
| 144 | """ |
---|
| 145 | """ |
---|
| 146 | grok.name('medicalhistory') |
---|
| 147 | |
---|
| 148 | fields = tuple( |
---|
| 149 | sorted(iface_names( |
---|
| 150 | IMedicalHistory, exclude_attribs=False,))) + ( |
---|
| 151 | 'student_id','display_fullname', 'matric_number', 'faccode', |
---|
[17395] | 152 | 'depcode', 'state','current_session', 'current_level', 'genotype', 'bloodgroup') |
---|
[16390] | 153 | title = 'Medical Questionnaire Data' |
---|
| 154 | |
---|
| 155 | def mangle_value(self, value, name, context=None): |
---|
| 156 | """The mangler determines the titles of faculty, department |
---|
| 157 | and certificate. It also computes the path of passport image file |
---|
| 158 | stored in the filesystem. |
---|
| 159 | """ |
---|
| 160 | if context is not None: |
---|
| 161 | student = context.student |
---|
| 162 | if name in ('student_id','display_fullname', |
---|
| 163 | 'matric_number', 'faccode', |
---|
| 164 | 'depcode', 'state','current_session', |
---|
[17395] | 165 | 'current_level', |
---|
| 166 | 'genotype', 'bloodgroup') and student is not None: |
---|
[16390] | 167 | value = getattr(student, name, None) |
---|
| 168 | return super( |
---|
| 169 | MedicalHistoryExporter, self).mangle_value( |
---|
| 170 | value, name, context=context) |
---|
[17396] | 171 | |
---|
| 172 | |
---|
| 173 | class NYSCExporter(SchoolFeePaymentsOverviewExporter): |
---|
| 174 | """ |
---|
| 175 | """ |
---|
| 176 | grok.name('nysc') |
---|
| 177 | curr_year = datetime.now().year |
---|
| 178 | year_range = range(curr_year - 11, curr_year + 1) |
---|
| 179 | year_range_tuple = tuple([str(year) for year in year_range]) |
---|
| 180 | fields = ('student_id', |
---|
| 181 | 'matric_number', |
---|
| 182 | 'reg_number', |
---|
| 183 | 'firstname', |
---|
| 184 | 'middlename', |
---|
| 185 | 'lastname', |
---|
| 186 | 'sex', |
---|
| 187 | #'email', |
---|
| 188 | #'phone', |
---|
| 189 | 'nationality', |
---|
| 190 | 'date_of_birth', |
---|
| 191 | 'state', |
---|
| 192 | 'current_mode', |
---|
| 193 | 'certcode', |
---|
| 194 | 'faccode', |
---|
| 195 | 'depcode', |
---|
| 196 | 'current_level', |
---|
| 197 | 'current_session', |
---|
| 198 | 'current_verdict', |
---|
| 199 | 'entry_session' |
---|
| 200 | 'faccode', |
---|
| 201 | 'depcode', |
---|
| 202 | 'certcode', |
---|
| 203 | ) + year_range_tuple |
---|
| 204 | title = u'NYSC Indication' |
---|
| 205 | |
---|
| 206 | def filter_func(self, x, **kw): |
---|
| 207 | students = list() |
---|
| 208 | for student in x: |
---|
| 209 | if student.nysc == True: |
---|
| 210 | students.append(student) |
---|
| 211 | return students |
---|