Changeset 15150 for main/waeup.kofa


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

Print electronic signatures on pdf files.

Remove final transcript file when resetting the transcript process.

Location:
main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students
Files:
5 edited

Legend:

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

    r15149 r15150  
    11881188        if prev_transcript_signees == None:
    11891189            prev_transcript_signees = ''
    1190         self.context.student.transcript_signees = '''Signed by %s (%s) on %s
    1191 
    1192 %s''' % (self.request.principal.title, self.request.principal.id, today,
    1193             prev_transcript_signees)
     1190        self.context.student.transcript_signees = (
     1191            u"Electronically signed by %s (%s) on %s\n%s"
     1192            % (self.request.principal.title, self.request.principal.id, today,
     1193            prev_transcript_signees))
     1194        self.redirect(self.url(self.context) + '/transcript')
    11941195        return
    11951196
     
    12211222            self.correspondence = ''
    12221223        if self.context.transcript_signees is not None:
    1223             self.signees = self.context.transcript_signees.replace('\n', '<br>')
     1224            self.signees = self.context.transcript_signees.replace(
     1225                '\n', '<br><br>')
    12241226        else:
    12251227            self.signees = ''
     
    12431245        self.context.writeLogMessage(
    12441246            self, 'comment: %s' % comment.replace('\n', '<br>'))
    1245         # Show and produce transcript file
     1247        # Produce transcript file
    12461248        self.redirect(self.url(self.context) + '/studycourse/transcript.pdf')
    12471249        return
     
    12731275
    12741276    def update(self):
    1275         if not self.context.student.transcript_enabled:
    1276             self.flash(_('You are not allowed to view the transcript.'),
    1277                        type="warning")
     1277        final_slip = getUtility(IExtFileStore).getFileByContext(
     1278            self.context.student, attr='final_transcript')
     1279        if not self.context.student.transcript_enabled or final_slip:
     1280            self.flash(_('Forbidden!'), type="warning")
    12781281            self.redirect(self.url(self.context))
    12791282            return
     
    13061309
    13071310    def update(self):
    1308         if not self.context.student.transcript_enabled:
    1309             self.flash(_('You are not allowed to download the transcript.'),
    1310                        type="warning")
     1311        final_slip = getUtility(IExtFileStore).getFileByContext(
     1312            self.context.student, attr='final_transcript')
     1313        if not self.context.student.transcript_enabled \
     1314            or final_slip:
     1315            self.flash(_('Forbidden!'), type="warning")
    13111316            self.redirect(self.url(self.context))
    13121317            return
     
    13271332
    13281333    def _sigsInFooter(self):
     1334        if self.context.student.transcript_signees:
     1335            return ()
    13291336        return (_('CERTIFIED TRUE COPY'),)
    13301337
    13311338    def _signatures(self):
    1332         return None
     1339        return ()
     1340
     1341    def _digital_sigs(self):
     1342        if self.context.student.transcript_signees:
     1343            return self.context.student.transcript_signees #.split('\n')
     1344        return ()
    13331345
    13341346    def _save_file(self):
     
    13641376            signatures=self._signatures(),
    13651377            sigs_in_footer=self._sigsInFooter(),
     1378            digital_sigs=self._digital_sigs(),
    13661379            save_file=self._save_file(),
    13671380            )
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/tests/test_browser.py

    r15148 r15150  
    21922192        prmglobal.assignRoleToPrincipal('waeup.TranscriptSignee', 'mrtranscript')
    21932193        self.browser.open(self.studycourse_path + '/transcript')
    2194         self.browser.getLink("Sign transcript").click()
     2194        self.browser.getLink("Sign transcript electronically").click()
    21952195        # Transcript signing has been logged ...
    21962196        logfile = os.path.join(
     
    22002200            'mrtranscript - students.browser.StudentTranscriptSignView - '
    22012201            'K1000000 - Transcript signed' in logcontent)
    2202         # ... and appears in the student's history
     2202        # ... appears in the student's history ...
    22032203        self.browser.open(self.history_path)
    22042204        self.assertTrue('Transcript signed by Ruth Gordon'
    22052205            in self.browser.contents)
     2206        # ... and is also stored in the transcript_signee attribute.
     2207        self.assertTrue(
     2208            u'Electronically signed by Ruth Gordon (mrtranscript) on '
     2209            in self.student.transcript_signees)
    22062210        # Officer can release the transcript
    22072211        self.browser.open(self.student_path)
     
    22452249        self.assertEqual(self.browser.headers['Content-Type'],
    22462250                         'application/pdf')
     2251        # Transcript views are no longer accesssible
     2252        self.browser.open(self.student_path)
     2253        self.assertFalse('studycourse/transcript' in self.browser.contents)
     2254        self.browser.open(self.studycourse_path)
     2255        self.assertFalse('studycourse/transcript' in self.browser.contents)
     2256        self.browser.open(self.studycourse_path + '/transcript')
     2257        self.assertTrue('Forbidden!' in self.browser.contents)
     2258        self.browser.open(self.studycourse_path + '/transcript.pdf')
     2259        self.assertTrue('Forbidden!' in self.browser.contents)
     2260        # If we reset the transcript process
     2261        # (can't be done by transcript officer), the file will be deleted
     2262        IWorkflowInfo(self.student).fireTransition('reset11')
     2263        self.browser.open(self.student_path)
     2264        self.assertFalse('Final Transcript' in self.browser.contents)
     2265
    22472266
    22482267class StudentUITests(StudentsFullSetup):
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/utils.py

    r15140 r15150  
    867867                  student=None,
    868868                  studentview=None,
    869                   note=None, signatures=None, sigs_in_footer=(),
     869                  note=None,
     870                  signatures=(),
     871                  sigs_in_footer=(),
     872                  digital_sigs=(),
    870873                  show_scans=True, topMargin=1.5,
    871874                  omit_fields=(),
     
    967970                signaturetables = get_signature_tables(signature)
    968971                data.append(signaturetables[0])
     972
     973        # Insert digital signatures
     974        if digital_sigs:
     975            data.append(Spacer(1, 20))
     976            sigs = digital_sigs.split('\n')
     977            for sig in sigs:
     978                data.append(Paragraph(sig, NOTE_STYLE))
    969979
    970980        view.response.setHeader(
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/viewlets.py

    r15147 r15150  
    4040from waeup.kofa.students.workflow import (
    4141    ADMITTED, PAID, REQUESTED, CLEARED, REGISTERED, VALIDATED, GRADUATED,
    42     TRANSREQ, TRANSVAL)
     42    TRANSREQ, TRANSVAL, TRANSREL)
    4343from waeup.kofa.university.interfaces import ICourse
    4444
     
    738738    @property
    739739    def target_url(self):
    740         if self.context.student.transcript_enabled:
     740        final_slip = getUtility(IExtFileStore).getFileByContext(
     741            self.context.student, attr='final_transcript')
     742        if self.context.student.transcript_enabled and not final_slip:
    741743            return self.view.url(self.view.context, self.target)
    742744        return False
     
    810812    @property
    811813    def target_url(self):
    812         if self.context.student.transcript_enabled:
     814        final_slip = getUtility(IExtFileStore).getFileByContext(
     815            self.context.student, attr='final_transcript')
     816        if self.context.student.transcript_enabled \
     817            and not final_slip:
    813818            return self.view.url(self.view.context, self.target)
    814819        return False
     
    820825    grok.view(StudyCourseTranscriptPage)
    821826    grok.require('waeup.signTranscript')
    822     text = _('Sign transcript')
     827    text = _('Sign transcript electronically')
    823828    target = 'sign_transcript'
    824829    icon = 'actionicon_transcript.png'
     
    833838    def onclick(self):
    834839        return "return window.confirm(%s);" % _(
    835             "'Signing a transcript cannot be revoked."
    836             "\\n\\n"
     840            "'Signing a transcript electronically cannot be revoked. "
     841            "The electronic signature replaces your handwritten signature.\\n\\n"
    837842            "You really want to sign the transcript?'")
    838843
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/workflow.py

    r15140 r15150  
    99    IObjectHistory, IKofaWorkflowInfo, IKofaUtils,
    1010    CREATED, ADMITTED, CLEARANCE, REQUESTED, CLEARED, PAID, RETURNING,
    11     REGISTERED, VALIDATED, GRADUATED, TRANSREQ, TRANSVAL, TRANSREL)
     11    REGISTERED, VALIDATED, GRADUATED, TRANSREQ, TRANSVAL, TRANSREL,
     12    IExtFileStore)
    1213from waeup.kofa.interfaces import MessageFactory as _
    1314from waeup.kofa.workflow import KofaWorkflow, KofaWorkflowInfo
     
    296297            level_object.validated_by = None
    297298            level_object.validation_date = None
     299    elif event.transition.transition_id == 'reset11':
     300        transcript_file = getUtility(IExtFileStore).getFileByContext(
     301            obj, attr='final_transcript')
     302        if transcript_file:
     303            getUtility(IExtFileStore).deleteFileByContext(
     304                obj, attr='final_transcript')
    298305    # In some tests we don't have a students container
    299306    try:
Note: See TracChangeset for help on using the changeset viewer.