Changeset 11607 for main/waeup.aaue


Ignore:
Timestamp:
30 Apr 2014, 05:30:32 (11 years ago)
Author:
Henrik Bettermann
Message:

ExportPDFMatricNumberSlipPage and MatricNumberSlipActionButton? added.

Location:
main/waeup.aaue/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/CHANGES.txt

    r11606 r11607  
    441.2dev (unreleased)
    55===================
     6
     7* ExportPDFMatricNumberSlipPage and MatricNumberSlipActionButton added.
    68
    79* Label of NigeriaExportPDFClearanceSlipPage customized.
  • main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py

    r11606 r11607  
    2323from waeup.kofa.interfaces import IKofaUtils
    2424from waeup.kofa.students.interfaces import IStudentsUtils, IStudent
     25from waeup.kofa.students.workflow import PAID
    2526from waeup.kofa.students.browser import (
    2627    StudentBasePDFFormPage,
     
    3940from waeup.aaue.students.interfaces import (
    4041    ICustomStudentOnlinePayment,
    41     ICustomStudentStudyLevel)
     42    ICustomStudentStudyLevel,
     43    ICustomStudent)
    4244from waeup.aaue.interfaces import MessageFactory as _
    4345
     
    222224    def render(self):
    223225        return
     226
     227class ExportPDFMatricNumberSlipPage(UtilityView, grok.View):
     228    """Deliver a PDF notification slip.
     229    """
     230    grok.context(ICustomStudent)
     231    grok.name('matric_number_slip.pdf')
     232    grok.require('waeup.viewStudent')
     233    prefix = 'form'
     234
     235    form_fields = grok.AutoFields(ICustomStudent).select(
     236        'student_id', 'matric_number')
     237    omit_fields = ('date_of_birth', 'current_level')
     238
     239    @property
     240    def label(self):
     241        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     242        return translate(_('Matriculation Number Slip\n'),
     243            'waeup.kofa', target_language=portal_language) \
     244            + ' %s' % self.context.display_fullname
     245
     246    def render(self):
     247        if self.context.state not in (PAID,) or not self.context.is_fresh \
     248            or not self.context.matric_number:
     249            self.flash('Not allowed.', type="danger")
     250            self.redirect(self.url(self.context))
     251            return
     252        students_utils = getUtility(IStudentsUtils)
     253        pre_text = _('Congratulations! Your acceptance and school fee payments ' +
     254                     'have been received and your matriculation number ' +
     255                     'generated with details as follows:')
     256        return students_utils.renderPDFAdmissionLetter(self,
     257            self.context.student, omit_fields=self.omit_fields,
     258            pre_text=pre_text, post_text='')
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r11605 r11607  
    2828from waeup.kofa.students.accommodation import BedTicket
    2929from waeup.kofa.testing import FunctionalTestCase
     30from waeup.kofa.browser.tests.test_pdf import samples_dir
    3031from waeup.aaue.testing import FunctionalLayer
    3132
     
    351352        self.student['studycourse'].certificate.study_mode = 'ug_pt'
    352353        self.browser.open(self.student_path)
     354        self.assertRaises(
     355            LinkNotFoundError,
     356            self.browser.getLink, 'Download matriculation number slip')
    353357        self.browser.getLink("Get Matriculation Number").click()
    354358        self.assertTrue('Matriculation number PTP/fac1/dep1/04/00001 assigned.'
     
    364368        self.assertTrue('E1000000 - waeup.aaue.students.browser.StudentGetMatricNumberPage - '
    365369                        'E1000000 - PTP/fac1/dep1/04/00001 assigned' in logcontent)
    366         return
    367 
     370        # Matric Number Slip can be downloaded
     371        self.browser.getLink("Download matriculation number slip").click()
     372        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     373        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     374        path = os.path.join(samples_dir(), 'transcript.pdf')
     375        open(path, 'wb').write(self.browser.contents)
     376        print "Sample PDF matric_number_slip.pdf written to %s" % path
     377        return
     378
  • main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py

    r11603 r11607  
    2020from zope.component import getUtility
    2121from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
     22from waeup.kofa.students.workflow import PAID
    2223from waeup.kofa.students.viewlets import (
    2324    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
     
    5657            return ''
    5758        return self.view.url(self.view.context, 'get_matric_number')
     59
     60class MatricNumberSlipActionButton(ManageActionButton):
     61    grok.order(10)
     62    grok.context(IStudent)
     63    grok.view(StudentBaseDisplayFormPage)
     64    grok.require('waeup.viewStudent')
     65    icon = 'actionicon_pdf.png'
     66    text = _('Download matriculation number slip')
     67    target = 'matric_number_slip.pdf'
     68
     69    @property
     70    def target_url(self):
     71        if self.context.state not in (PAID,) or not self.context.is_fresh \
     72            or not self.context.matric_number:
     73            return ''
     74        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.