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

Last change on this file since 17626 was 17624, checked in by Henrik Bettermann, 14 months ago

Export flash_notice.

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