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

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

Add NigeriaStudentStudyLevel? exporter.

  • Property svn:keywords set to Id
File size: 3.0 KB
RevLine 
[9042]1## $Id: export.py 11544 2014-03-27 11:01:44Z 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 (
[11544]21    INigeriaStudent,
22    INigeriaStudentStudyCourse,
23    INigeriaStudentStudyLevel,
24    INigeriaCourseTicket,
[10757]25    INigeriaStudentOnlinePayment)
[9042]26from waeup.kofa.students.export import (
[11544]27    StudentsExporter,
28    StudentStudyCourseExporter,
29    StudentStudyLevelExporter,
30    CourseTicketExporter,
[10757]31    StudentPaymentsExporter)
[9042]32from waeup.kofa.utils.helpers import iface_names
33
34class NigeriaStudentsExporter(StudentsExporter):
35    """Exporter for Students.
36    """
37
38    #: Fieldnames considered by this exporter
39    fields = tuple(sorted(iface_names(
40        INigeriaStudent, omit=['loggerInfo']))) + (
[9254]41        'password', 'state', 'history', 'certcode', 'is_postgrad',
42        'current_level', 'current_session')
[9042]43
[9044]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            NigeriaStudentsExporter, self).mangle_value(
49            value, name, context=context)
[9042]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
[11544]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')
[9042]66
67class NigeriaCourseTicketExporter(CourseTicketExporter):
68    """Exporter for CourseTickets.
69    """
70
71    #: Fieldnames considered by this exporter
72    fields = tuple(sorted(iface_names(INigeriaCourseTicket) +
[11491]73        ['level', 'code', 'level_session'])) + ('student_id',
74        'certcode', 'display_fullname')
[10757]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.