Changeset 8493


Ignore:
Timestamp:
23 May 2012, 05:59:19 (13 years ago)
Author:
Henrik Bettermann
Message:

Export student_id in all files.

Export password, state and history.

Not yet tested.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r8414 r8493  
    103103
    104104    #: Fieldnames considered by this exporter
    105     fields = tuple(sorted(iface_names(IStudent, omit=['loggerInfo'])))
     105    fields = tuple(sorted(iface_names(
     106        IStudent, omit=['loggerInfo']))) + (
     107        'password', 'state', 'history', 'certcode')
    106108
    107109    #: The title under which this exporter will be displayed
    108110    title = _(u'Students')
     111
     112    def mangle_value(self, value, name, context=None):
     113        if name == 'history':
     114            value = value.messages
     115        return super(
     116            StudentsExporter, self).mangle_value(
     117            value, name, context=context)
    109118
    110119    def export_all(self, site, filepath=None):
     
    125134
    126135    #: Fieldnames considered by this exporter
    127     fields = tuple(sorted(iface_names(IStudentStudyCourse)))
     136    fields = tuple(sorted(iface_names(IStudentStudyCourse))) + ('student_id',)
    128137
    129138    #: The title under which this exporter will be displayed
     
    131140
    132141    def mangle_value(self, value, name, context=None):
    133         """Add the hash symbol at the end of date_of_birth.
    134 
    135         This is to avoid annoying automatic date transformation
    136         by Excel or Calc.
     142        """Treat location values special.
    137143        """
    138144        if name == 'certificate' and value is not None:
    139145            # XXX: hopefully cert codes are unique site-wide
    140146            value = value.code
     147        if name == 'student_id' and context is not None:
     148            student = context.getStudent()
     149            value = getattr(student, name, None)
    141150        return super(
    142151            StudentStudyCourseExporter, self).mangle_value(
     
    162171
    163172    #: Fieldnames considered by this exporter
    164     fields = tuple(sorted(iface_names(IStudentStudyLevel) + [
    165         'reg_number', 'matric_number', 'level']))
     173    fields = tuple(sorted(iface_names(
     174        IStudentStudyLevel) + ['level'])) + ('student_id',)
    166175
    167176    #: The title under which this exporter will be displayed
     
    169178
    170179    def mangle_value(self, value, name, context=None):
    171         """Add the hash symbol at the end of date_of_birth.
    172 
    173         This is to avoid annoying automatic date transformation
    174         by Excel or Calc.
    175         """
    176 
    177         if name == 'reg_number' and context is not None:
    178             value = getattr(
    179                 getattr(getattr(context, '__parent__', None),
    180                         '__parent__', None), 'reg_number', None)
    181         if name == 'matric_number' and context is not None:
    182             value = getattr(
    183                 getattr(getattr(context, '__parent__', None),
    184                         '__parent__', None), 'matric_number', None)
     180        """Treat location values special.
     181        """
     182        if name == 'student_id' and context is not None:
     183            student = context.getStudent()
     184            value = getattr(student, name, None)
    185185        return super(
    186186            StudentStudyLevelExporter, self).mangle_value(
     
    203203
    204204    #: Fieldnames considered by this exporter
    205     fields = tuple(sorted(iface_names(ICourseTicket) + [
    206         'reg_number', 'matric_number', 'level', 'code', 'title', 'credits',
    207         'passmark', 'semester', 'fcode', 'dcode']))
     205    fields = tuple(sorted(iface_names(ICourseTicket) +
     206        ['level', 'code', 'title', 'credits',
     207        'passmark', 'semester', 'fcode', 'dcode'])) + ('student_id',)
    208208
    209209    #: The title under which this exporter will be displayed
     
    215215        if context is not None:
    216216            student = context.getStudent()
    217             if name in ['reg_number', 'matric_number'] and student is not None:
     217            if name == 'student_id' and student is not None:
    218218                value = getattr(student, name, None)
    219219            if name == 'level':
     
    241241    #: Fieldnames considered by this exporter
    242242    fields = tuple(
    243         sorted(['reg_number', 'matric_number'] +
    244                iface_names(IStudentOnlinePayment, exclude_attribs=False)))
     243        sorted(iface_names(
     244            IStudentOnlinePayment, exclude_attribs=False))) + ('student_id',)
    245245
    246246    #: The title under which this exporter will be displayed
     
    252252        if context is not None:
    253253            student = context.getStudent()
    254             if name in ['reg_number', 'matric_number'] and student is not None:
     254            if name in ['student_id'] and student is not None:
    255255                value = getattr(student, name, None)
    256256        return super(
Note: See TracChangeset for help on using the changeset viewer.