Ignore:
Timestamp:
6 Sep 2018, 11:16:55 (6 years ago)
Author:
Henrik Bettermann
Message:

Extend transcript workflow (par 1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/utils.py

    r15102 r15128  
    2020import grok
    2121from time import time
     22from cStringIO import StringIO
    2223from reportlab.lib import colors
    2324from reportlab.lib.units import cm
     
    3334from waeup.kofa.interfaces import (
    3435    IExtFileStore, IKofaUtils, RETURNING, PAID, CLEARED,
    35     academic_sessions_vocab)
     36    academic_sessions_vocab, IFileStoreNameChooser)
    3637from waeup.kofa.interfaces import MessageFactory as _
    3738from waeup.kofa.students.interfaces import IStudentsUtils
     
    854855            level_obj.cumulative_params[0], level_obj.student)[0]
    855856
     857    def _saveTranscriptPDF(self, student, transcript):
     858        """Create a transcript PDF file and store it in student folder.
     859        """
     860        file_store = getUtility(IExtFileStore)
     861        file_id = IFileStoreNameChooser(student).chooseName(
     862            attr="transcript.pdf")
     863        file_store.createFile(file_id, StringIO(transcript))
     864        return
     865
    856866    def renderPDFTranscript(self, view, filename='transcript.pdf',
    857867                  student=None,
     
    861871                  omit_fields=(),
    862872                  tableheader=None,
    863                   no_passport=False):
     873                  no_passport=False,
     874                  save_file=False):
    864875        """Render pdf slip of a transcripts.
    865876        """
     
    966977            view.flash(_('Error in image file.'))
    967978            return view.redirect(view.url(view.context))
     979        if save_file:
     980            self._saveTranscriptPDF(student, pdf_stream)
    968981        return pdf_stream
    969982
Note: See TracChangeset for help on using the changeset viewer.