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

Last change on this file since 9247 was 9044, checked in by Henrik Bettermann, 12 years ago

Export school results as strings.

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1## $Id: export.py 9044 2012-07-25 05:36:48Z 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)
22from waeup.kofa.students.export import (
23    StudentsExporter, StudentStudyCourseExporter, CourseTicketExporter)
24from waeup.kofa.utils.helpers import iface_names
25
26class NigeriaStudentsExporter(StudentsExporter):
27    """Exporter for Students.
28    """
29
30    #: Fieldnames considered by this exporter
31    fields = tuple(sorted(iface_names(
32        INigeriaStudent, omit=['loggerInfo']))) + (
33        'password', 'state', 'history', 'certcode')
34
35    def mangle_value(self, value, name, context=None):
36        if '_result' in name and value:
37            value = [eval(entry.to_string()) for entry in value]
38        return super(
39            NigeriaStudentsExporter, self).mangle_value(
40            value, name, context=context)
41
42class NigeriaStudentStudyCourseExporter(StudentStudyCourseExporter):
43    """Exporter for StudentStudyCourses.
44    """
45
46    #: Fieldnames considered by this exporter
47    fields = tuple(
48        sorted(iface_names(INigeriaStudentStudyCourse))) + ('student_id',)
49
50
51class NigeriaCourseTicketExporter(CourseTicketExporter):
52    """Exporter for CourseTickets.
53    """
54
55    #: Fieldnames considered by this exporter
56    fields = tuple(sorted(iface_names(INigeriaCourseTicket) +
57        ['level', 'code', 'title', 'credits',
58        'passmark', 'semester', 'fcode', 'dcode'])) + ('student_id',)
Note: See TracBrowser for help on using the repository browser.