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

Last change on this file since 12080 was 12080, checked in by Henrik Bettermann, 10 years ago

Rename some exporter classes: singular not plural.

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