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

Last change on this file since 17797 was 17785, checked in by Henrik Bettermann, 6 months ago

Add physical_clearance_date to exporter.

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