source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/export.py @ 16281

Last change on this file since 16281 was 15400, checked in by Henrik Bettermann, 6 years ago

Add entry_session to students exporter.

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