source: main/waeup.aaue/trunk/src/waeup/aaue/students/export.py @ 13713

Last change on this file since 13713 was 13569, checked in by Henrik Bettermann, 9 years ago

Add matric_number to export file.

  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1## $Id: export.py 13569 2016-01-06 08:21:17Z henrik $
2##
3## Copyright (C) 2011 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"""
20from waeup.kofa.utils.batching import ExporterBase
21from waeup.aaue.students.interfaces import (
22    ICustomStudent, ICustomStudentStudyCourse,
23    ICustomStudentStudyLevel,
24    ICustomCourseTicket,
25    ICustomStudentOnlinePayment)
26from kofacustom.nigeria.students.export import (
27    NigeriaStudentExporter, NigeriaStudentStudyCourseExporter,
28    NigeriaStudentStudyLevelExporter,
29    NigeriaCourseTicketExporter, NigeriaStudentPaymentExporter)
30from waeup.kofa.utils.helpers import iface_names
31
32class CustomStudentExporter(NigeriaStudentExporter):
33    """Exporter for Students.
34    """
35
36    fields = tuple(sorted(iface_names(
37        ICustomStudent, omit=['loggerInfo']))) + (
38        'password', 'state', 'history', 'certcode', 'is_postgrad',
39        'current_level', 'current_session')
40
41class CustomStudentStudyCourseExporter(NigeriaStudentStudyCourseExporter):
42    """Exporter for StudentStudyCourses.
43    """
44
45    fields = tuple(
46        sorted(iface_names(ICustomStudentStudyCourse))) + ('student_id',)
47
48class CustomCourseTicketExporter(NigeriaCourseTicketExporter):
49    """Exporter for CourseTickets.
50    """
51
52    fields = tuple(sorted(iface_names(ICustomCourseTicket) +
53        ['level', 'code', 'level_session'])) + ('student_id',
54        'certcode', 'display_fullname', 'matric_number')
55
56    def mangle_value(self, value, name, context=None):
57        """The mangler determines the student's id and fullname.
58        """
59        if context is not None:
60            student = context.student
61            if name in ('student_id', 'display_fullname', 'matric_number') \
62                and student is not None:
63                value = getattr(student, name, None)
64        return ExporterBase().mangle_value(value, name, context=context)
65
66class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter):
67    """Exporter for StudentStudyLevels.
68    """
69    #: Fieldnames considered by this exporter
70    fields = tuple(sorted(iface_names(
71        ICustomStudentStudyLevel))) + (
72        'student_id', 'number_of_tickets','certcode')
73
74class CustomStudentPaymentExporter(NigeriaStudentPaymentExporter):
75    """Exporter for OnlinePayment instances.
76    """
77
78    fields = tuple(
79        sorted(iface_names(
80            ICustomStudentOnlinePayment, exclude_attribs=False,
81            omit=['display_item']))) + (
82            'student_id','state','current_session')
83
Note: See TracBrowser for help on using the repository browser.