source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/export.py @ 11154

Last change on this file since 11154 was 10757, checked in by Henrik Bettermann, 11 years ago

Use the customized interface when exporting Nigerian payment tickets.

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1## $Id: export.py 10757 2013-11-18 15:30:05Z 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 kofacustom.nigeria.students.interfaces import (
21    INigeriaStudent, INigeriaStudentStudyCourse, INigeriaCourseTicket,
22    INigeriaStudentOnlinePayment)
23from waeup.kofa.students.export import (
24    StudentsExporter, StudentStudyCourseExporter, CourseTicketExporter,
25    StudentPaymentsExporter)
26from waeup.kofa.utils.helpers import iface_names
27
28class NigeriaStudentsExporter(StudentsExporter):
29    """Exporter for Students.
30    """
31
32    #: Fieldnames considered by this exporter
33    fields = tuple(sorted(iface_names(
34        INigeriaStudent, omit=['loggerInfo']))) + (
35        'password', 'state', 'history', 'certcode', 'is_postgrad',
36        'current_level', 'current_session')
37
38    def mangle_value(self, value, name, context=None):
39        if '_result' in name and value:
40            value = [eval(entry.to_string()) for entry in value]
41        return super(
42            NigeriaStudentsExporter, self).mangle_value(
43            value, name, context=context)
44
45class NigeriaStudentStudyCourseExporter(StudentStudyCourseExporter):
46    """Exporter for StudentStudyCourses.
47    """
48
49    #: Fieldnames considered by this exporter
50    fields = tuple(
51        sorted(iface_names(INigeriaStudentStudyCourse))) + ('student_id',)
52
53
54class NigeriaCourseTicketExporter(CourseTicketExporter):
55    """Exporter for CourseTickets.
56    """
57
58    #: Fieldnames considered by this exporter
59    fields = tuple(sorted(iface_names(INigeriaCourseTicket) +
60        ['level', 'code', 'level_session'])) + ('student_id', 'certcode')
61
62class NigeriaStudentPaymentsExporter(StudentPaymentsExporter):
63    """Exporter for OnlinePayment instances.
64    """
65
66    #: Fieldnames considered by this exporter
67    fields = tuple(
68        sorted(iface_names(
69            INigeriaStudentOnlinePayment, exclude_attribs=False,
70            omit=['display_item']))) + (
71            'student_id','state','current_session')
Note: See TracBrowser for help on using the repository browser.