Changeset 7028


Ignore:
Timestamp:
8 Nov 2011, 07:21:58 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement ExportPDFCourseRegistrationSlipPage (work in progess).

PDF payment receipt mustn't be available if ticket has not yet been paid.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7027 r7028  
    642642        return total_credits
    643643
     644class CourseRegistrationSlipActionButton(ManageActionButton):
     645    grok.order(1)
     646    grok.context(IStudentStudyLevel)
     647    grok.require('waeup.viewStudent')
     648    icon = 'actionicon_pdf.png'
     649    text = 'Download course registration slip'
     650    target = 'course_registration.pdf'
     651
     652class ExportPDFCourseRegistrationSlipPage(grok.View):
     653    """Deliver a PDF slip of the context.
     654    """
     655    grok.context(IStudentStudyLevel)
     656    grok.name('course_registration.pdf')
     657    grok.require('waeup.viewStudent')
     658    form_fields = grok.AutoFields(IStudentStudyLevel)
     659    prefix = 'form'
     660
     661    @property
     662    def label(self):
     663        return 'Course Registration Slip %s' % self.context.level_title
     664
     665    def render(self):
     666        studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
     667            self.request)
     668        return renderPDF(self,'Course Registration', 'course_registration.pdf',
     669            self.context.getStudent, studentview)
     670
    644671class StudyLevelManageActionButton(ManageActionButton):
    645     grok.order(1)
     672    grok.order(2)
    646673    grok.context(IStudentStudyLevel)
    647674    grok.view(StudyLevelDisplayFormPage)
     
    9801007
    9811008class PaymentReceiptActionButton(ManageActionButton):
     1009    grok.order(1)
    9821010    grok.context(IStudentOnlinePayment)
    9831011    grok.require('waeup.viewStudent')
     
    9851013    text = 'Download payment receipt'
    9861014    target = 'payment_receipt.pdf'
     1015
     1016    @property
     1017    def target_url(self):
     1018        if self.context.p_state != 'paid':
     1019            return ''
     1020        return self.view.url(self.view.context, self.target)
    9871021
    9881022class OnlinePaymentCallbackPage(grok.View):
     
    10511085
    10521086    def render(self):
     1087        if self.context.p_state != 'paid':
     1088            self.flash('Ticket not yet paid.')
     1089            self.redirect(self.url(self.context))
     1090            return
    10531091        studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
    10541092            self.request)
     
    12661304
    12671305class BedTicketSlipActionButton(ManageActionButton):
     1306    grok.order(1)
    12681307    grok.context(IBedTicket)
    12691308    grok.require('waeup.viewStudent')
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7027 r7028  
    700700        payment_url = self.browser.url
    701701
     702        # The pdf payment receipt can't yet be opened
     703        self.browser.open(payment_url + '/payment_receipt.pdf')
     704        self.assertMatches('...Ticket not yet paid...',
     705                           self.browser.contents)
     706
    702707        # The same payment ticket (with same p_item, p_session and p_category)
    703708        # can't be added twice.
     
    721726
    722727        # Managers can open the pdf payment receipt
    723         self.browser.open(payment_url + '/payment_receipt.pdf')
     728        self.browser.getLink("Download payment receipt").click()
    724729        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    725730        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
Note: See TracChangeset for help on using the changeset viewer.