Changeset 16906 for main/waeup.uniben


Ignore:
Timestamp:
25 Mar 2022, 12:12:29 (3 years ago)
Author:
Henrik Bettermann
Message:

Allow students to view transcripts but with different watermark.

Location:
main/waeup.uniben/trunk/src/waeup/uniben
Files:
1 added
5 edited

Legend:

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

    r15425 r16906  
    2828    """
    2929
    30     header_logo_path = os.path.join(
    31         os.path.dirname(__file__), 'static', 'pdf_logo.jpg')
    32     watermark_path = os.path.join(
    33         os.path.dirname(__file__), 'static', 'pdf_watermark.jpg')
    34 
    3530    watermark_pos = [-25, 100]
    3631    logo_pos = [507, 720, 40]
    3732
     33    header_logo_path = os.path.join(
     34        os.path.dirname(__file__), 'static', 'pdf_logo.jpg')
     35
     36    @property
     37    def watermark_path(self):
     38        if self.view and self.view.__name__ == 'transcript.pdf':
     39            usertype = getattr(self.view.request.principal, 'user_type', None)
     40            if usertype and usertype == 'student':
     41                self.watermark_pos = [95, 190]
     42                return os.path.join(
     43                    os.path.dirname(__file__), 'static', 'pdf_stud_only.jpg')
     44        return os.path.join(
     45            os.path.dirname(__file__), 'static', 'pdf_watermark.jpg')
    3846
    3947class CustomLandscapePDFCreator(LandscapePDFCreator):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r16797 r16906  
    4040    PaymentsManageFormPage,
    4141    StartClearancePage,
    42     StudentFilesUploadPage)
     42    StudentFilesUploadPage,
     43    StudyCourseTranscriptPage)
    4344from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID,
    4445    CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED,
     
    704705        return
    705706
     707class CustomStudyCourseTranscriptPage(StudyCourseTranscriptPage):
     708    """ Page to display the student's transcript.
     709    """
     710    grok.require('waeup.viewStudent')
     711
    706712class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip):
    707713    """Deliver a PDF slip of the context.
    708714    """
     715    grok.require('waeup.viewStudent')
    709716
    710717    def _sigsInFooter(self):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r16458 r16906  
    10091009        self.assertEqual(td[0][1]['tickets_1'][0].code, 'ANYCODE')
    10101010        self.assertEqual(td[1], 3.5652173913043477)
    1011         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1011        self.browser.open(self.login_path)
     1012        self.browser.getControl(name="form.login").value = self.student_id
     1013        self.browser.getControl(name="form.password").value = 'spwd'
     1014        self.browser.getControl("Login").click()
    10121015        self.browser.open(self.student_path + '/studycourse/transcript')
    10131016        self.assertEqual(self.browser.headers['Status'], '200 Ok')
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r16873 r16906  
    645645            pdf_stream = creator.create_pdf(
    646646                data, None, doc_title, author=author, footer=footer_text,
    647                 note=note, sigs_in_footer=sigs_in_footer, topMargin=topMargin)
     647                note=note, sigs_in_footer=sigs_in_footer, topMargin=topMargin,
     648                view=view)
    648649        except IOError:
    649650            view.flash(_('Error in image file.'))
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r16808 r16906  
    2929    StudentBaseDisplayFormPage, OnlinePaymentDisplayFormPage)
    3030from waeup.kofa.students.viewlets import (
    31     RequestTranscriptActionButton, StudentPassportActionButton)
     31    RequestTranscriptActionButton, StudentPassportActionButton,
     32    TranscriptSlipActionButton,
     33    StudyCourseTranscriptActionButton)
    3234
    3335from waeup.uniben.students.interfaces import (
     
    4446    def target_url(self):
    4547        return ''
     48
     49class TranscriptSlipActionButton(TranscriptSlipActionButton):
     50    grok.require('waeup.viewStudent')
     51
     52class StudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton):
     53    grok.require('waeup.viewStudent')
    4654
    4755class StudentPassportActionButton(StudentPassportActionButton):
Note: See TracChangeset for help on using the changeset viewer.