Changeset 16967


Ignore:
Timestamp:
16 Jun 2022, 07:19:57 (3 years ago)
Author:
Henrik Bettermann
Message:

Implement transcript slip student view.

Location:
main/waeup.aaue/trunk/src/waeup/aaue
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/browser/pdf.py

    r14496 r16967  
    3232    header_logo_path = os.path.join(
    3333        os.path.dirname(__file__), 'static', 'pdf_logo.jpg')
    34     #watermark_path = os.path.join(
    35     #    os.path.dirname(__file__), 'static', 'pdf_watermark.jpg')
    3634
    3735    #watermark_pos = [70, 150]
    3836    logo_pos = [500, 708, 60]
     37
     38    @property
     39    def watermark_path(self):
     40        if self.view and self.view.__name__ == 'transcript_studview.pdf':
     41            self.watermark_pos = [95, 190]
     42            return os.path.join(
     43                os.path.dirname(__file__), 'static', 'pdf_stud_only.jpg')
     44        return
    3945
    4046class CustomLandscapePDFCreator(LandscapePDFCreator):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py

    r16934 r16967  
    794794                         (Cred, 'credits', 1.5),
    795795                         (Score, 'total_score', 1.5),
     796                         (Grade, 'grade', 1.5),
     797                         ]
     798
     799        pdfstream = students_utils.renderPDFTranscript(
     800            self, 'transcript.pdf',
     801            self.context.student, studentview,
     802            omit_fields=self.omit_fields,
     803            tableheader=tableheader,
     804            signatures=self._signatures(),
     805            sigs_in_footer=self._sigsInFooter(),
     806            digital_sigs=self._digital_sigs(),
     807            save_file=self._save_file(),
     808            )
     809        if not pdfstream:
     810            self.redirect(self.url(self.context.student))
     811            return
     812        return pdfstream
     813
     814class ExportPDFTranscriptStudViewSlip(CustomExportPDFTranscriptSlip):
     815    """Deliver a PDF slip of the context.
     816    """
     817
     818    grok.name('transcript_studview.pdf')
     819
     820    def render(self):
     821        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     822        Term = translate(_('Sem.'), target_language=portal_language)
     823        Code = translate(_('Code'), target_language=portal_language)
     824        Title = translate(_('Title'), target_language=portal_language)
     825        Cred = translate(_('Credits'), target_language=portal_language)
     826        #Score = translate(_('Score'), target_language=portal_language)
     827        Grade = translate(_('Grade'), target_language=portal_language)
     828        studentview = StudentBasePDFFormPage(self.context.student,
     829            self.request, self.omit_fields)
     830        students_utils = getUtility(IStudentsUtils)
     831
     832        tableheader = [(Code,'code', 2.5),
     833                         (Title,'title', 7),
     834                         (Term, 'semester', 1.5),
     835                         (Cred, 'credits', 1.5),
     836                         #(Score, 'total_score', 1.5),
    796837                         (Grade, 'grade', 1.5),
    797838                         ]
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r16900 r16967  
    554554        open(path, 'wb').write(self.browser.contents)
    555555        print "Sample PDF transcript.pdf written to %s" % path
     556        # Officers can open the pdf student viewtranscript
     557        self.browser.open(self.student_path + '/studycourse/transcript_studview.pdf')
     558        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     559        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     560        path = os.path.join(samples_dir(), 'transcript_studview.pdf')
     561        open(path, 'wb').write(self.browser.contents)
     562        print "Sample PDF transcript_studview.pdf written to %s" % path
    556563
    557564    def test_payment_disabled(self):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py

    r15424 r16967  
    148148    grok.name('transcript_slip')
    149149
     150class TranscriptStudviewSlipActionButton(CustomTranscriptSlipActionButton):
     151    #grok.require('waeup.viewStudent')
     152    grok.name('transcript_slip_studview')
     153    target = 'transcript_studview.pdf'
     154    text = _('Academic Transcript (Student View)')
     155
    150156class StudyLevelRepairActionButton(ManageActionButton):
    151157    grok.order(2)
Note: See TracChangeset for help on using the changeset viewer.