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

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

Add email2 and sex.

File size: 5.8 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(
86        sorted(iface_names(ICustomStudentStudyCourse))) + ('student_id',)
87
88class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter):
89    """Exporter for StudentStudyLevels.
90    """
91    #: Fieldnames considered by this exporter
92    fields = tuple(sorted(iface_names(
[12879]93        ICustomStudentStudyLevel))) + (
[12856]94        'student_id', 'number_of_tickets','certcode')
95
96class CustomCourseTicketExporter(NigeriaCourseTicketExporter):
97    """Exporter for CourseTickets.
98    """
99
100    fields = tuple(sorted(iface_names(ICustomCourseTicket) +
101        ['level', 'code', 'level_session'])) + ('student_id',
102        'certcode', 'display_fullname')
103
[12879]104class CustomStudentPaymentExporter(NigeriaStudentPaymentExporter):
[12856]105    """Exporter for OnlinePayment instances.
106    """
107
108    fields = tuple(
109        sorted(iface_names(
110            ICustomStudentOnlinePayment, exclude_attribs=False,
[13621]111            omit=['display_item']))) + (
[12856]112            'student_id','state','current_session')
113
[14856]114class CustomDataForBursaryExporter(NigeriaDataForBursaryExporter):
115    """
116    """
117
118    fields = tuple(
119        sorted(iface_names(
120            ICustomStudentOnlinePayment, exclude_attribs=False,
121            omit=['display_item', 'certificate', 'student']))) + (
122            'student_id','matric_number','reg_number',
123            'firstname', 'middlename', 'lastname',
124            'state','current_session',
125            'entry_session', 'entry_mode',
126            'faccode', 'depcode','certcode')
[15025]127
[15048]128class CustomSchoolFeePaymentsOverviewExporter(SchoolFeePaymentsOverviewExporter):
[15025]129
130    curr_year = datetime.now().year
[15044]131    year_range = range(curr_year - 14, curr_year + 1) # 3 more years in Uniben
[15025]132    year_range_tuple = tuple([str(year) for year in year_range])
133
[16476]134    fields = ('student_id', 'matric_number', 'firstname', 'middlename',
135        'lastname', 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad',
[15025]136        'current_level', 'current_session', 'current_mode',
[16498]137        'entry_session', 'reg_number', 'email2', 'sex'
[15025]138        ) + year_range_tuple
[16390]139
140class MedicalHistoryExporter(grok.GlobalUtility, StudentExporterBase):
141    """
142    """
143    grok.name('medicalhistory')
144
145    fields = tuple(
146        sorted(iface_names(
147            IMedicalHistory, exclude_attribs=False,))) + (
148            'student_id','display_fullname', 'matric_number', 'faccode',
149            'depcode', 'state','current_session', 'current_level')
150    title = 'Medical Questionnaire Data'
151
152    def mangle_value(self, value, name, context=None):
153        """The mangler determines the titles of faculty, department
154        and certificate. It also computes the path of passport image file
155        stored in the filesystem.
156        """
157        if context is not None:
158            student = context.student
159            if name in ('student_id','display_fullname',
160                'matric_number', 'faccode',
161                'depcode', 'state','current_session',
162                'current_level') and student is not None:
163                value = getattr(student, name, None)
164        return super(
165            MedicalHistoryExporter, self).mangle_value(
166            value, name, context=context)
Note: See TracBrowser for help on using the repository browser.