source: main/waeup.uniben/trunk/src/waeup/uniben/students/export.py @ 17558

Last change on this file since 17558 was 17558, checked in by Henrik Bettermann, 15 months ago

Export matric_number.

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