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

Last change on this file since 17238 was 16837, checked in by Henrik Bettermann, 3 years ago

Adjust to base package.

File size: 5.8 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
81class CustomStudentStudyCourseExporter(NigeriaStudentStudyCourseExporter):
82    """Exporter for StudentStudyCourses.
83    """
84
85    fields = tuple(
86        sorted(iface_names(ICustomStudentStudyCourse))) + (
87            'student_id', 'previous')
88
89class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter):
90    """Exporter for StudentStudyLevels.
91    """
92    #: Fieldnames considered by this exporter
93    fields = tuple(sorted(iface_names(
94        ICustomStudentStudyLevel))) + (
95        'student_id', 'number_of_tickets','certcode', 'previous')
96
97class CustomCourseTicketExporter(NigeriaCourseTicketExporter):
98    """Exporter for CourseTickets.
99    """
100
101    fields = tuple(sorted(iface_names(ICustomCourseTicket) +
102        ['level', 'code', 'level_session'])) + ('student_id',
103        'certcode', 'display_fullname', 'previous')
104
105class CustomStudentPaymentExporter(NigeriaStudentPaymentExporter):
106    """Exporter for OnlinePayment instances.
107    """
108
109    fields = tuple(
110        sorted(iface_names(
111            ICustomStudentOnlinePayment, exclude_attribs=False,
112            omit=['display_item']))) + (
113            'student_id','state','current_session')
114
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')
128
129class CustomSchoolFeePaymentsOverviewExporter(SchoolFeePaymentsOverviewExporter):
130
131    curr_year = datetime.now().year
132    year_range = range(curr_year - 14, curr_year + 1) # 3 more years in Uniben
133    year_range_tuple = tuple([str(year) for year in year_range])
134
135    fields = ('student_id', 'matric_number', 'firstname', 'middlename',
136        'lastname', 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad',
137        'current_level', 'current_session', 'current_mode',
138        'entry_session', 'reg_number', 'email2', 'sex'
139        ) + year_range_tuple
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',
150            'depcode', 'state','current_session', 'current_level')
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',
163                'current_level') and student is not None:
164                value = getattr(student, name, None)
165        return super(
166            MedicalHistoryExporter, self).mangle_value(
167            value, name, context=context)
Note: See TracBrowser for help on using the repository browser.