Ignore:
Timestamp:
28 Aug 2024, 07:48:13 (4 months ago)
Author:
Henrik Bettermann
Message:

Export routing_slip_path with Trimmed Data Exporter.

File:
1 edited

Legend:

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

    r17897 r17905  
    1919"""
    2020import grok
     21import os
    2122from datetime import datetime
    22 from waeup.kofa.interfaces import IKofaUtils
     23from waeup.kofa.interfaces import (
     24    IExtFileStore, IFileStoreNameChooser, IKofaUtils)
    2325from zope.component import getUtility
    2426from waeup.uniben.students.interfaces import (
     
    8587        'former_matric',
    8688        'hq_matric_no',
    87         'hq2_matric_no')
     89        'hq2_matric_no',
     90        'routing_slip_path')
     91
     92    def mangle_value(self, value, name, context=None):
     93        if name == 'routing_slip_path':
     94            file_id = IFileStoreNameChooser(context).chooseName(
     95                attr='routingslip.pdf')
     96            os_path = getUtility(IExtFileStore)._pathFromFileID(file_id)
     97            if not os.path.exists(os_path):
     98                value = None
     99            else:
     100                value = '/'.join(os_path.split('/')[-4:])
     101        return super(
     102            CustomTrimmedDataExporter, self).mangle_value(
     103            value, name, context=context)
     104
    88105
    89106class CustomStudentStudyCourseExporter(NigeriaStudentStudyCourseExporter):
Note: See TracChangeset for help on using the changeset viewer.