Ignore:
Timestamp:
3 Dec 2014, 05:14:41 (10 years ago)
Author:
Henrik Bettermann
Message:

Add clearance invitation slip.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
3 edited

Legend:

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

    r11552 r12121  
    2424    REQUESTED, IExtFileStore, IKofaUtils, IObjectHistory)
    2525from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    26 from waeup.kofa.browser.layout import action, KofaEditFormPage
     26from waeup.kofa.browser.layout import action, KofaEditFormPage, UtilityView
    2727from waeup.kofa.students.browser import (
    2828    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
     
    4343
    4444from waeup.uniben.students.interfaces import (
     45    ICustomStudent,
    4546    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
    4647    ICustomStudentStudyLevel,
     
    125126            sigs_in_footer=self._sigsInFooter(), show_scans=False,
    126127            omit_fields=self.omit_fields)
     128
     129
     130class ExportClearanceInvitationSlipPage(UtilityView, grok.View):
     131    """Deliver an invitation letter to physical clearance.
     132
     133    This form page is available only in Uniben.
     134    """
     135    grok.context(ICustomStudent)
     136    grok.name('clearance_invitation_slip.pdf')
     137    grok.require('waeup.viewStudent')
     138    prefix = 'form'
     139
     140    label = u'Invitation Letter to Physical Clearance'
     141
     142    omit_fields = (
     143        'suspended', 'phone', 'email',
     144        'adm_code', 'suspended_comment',
     145        'date_of_birth', 'current_level',
     146        'faculty', 'department', 'current_mode',
     147        'entry_session', 'matric_number', 'sex')
     148
     149    form_fields = []
     150
     151    @property
     152    def note(self):
     153        if self.context.physical_clearance_date:
     154            return """
     155<br /><br /><br /><br /><font size="12">
     156You are kindly invited to physical clearance on %s
     157
     158<br /><br />
     159Clearance Officer<br />
     160</font>
     161
     162""" % self.context.physical_clearance_date
     163        return
     164
     165    def render(self):
     166        studentview = StudentBasePDFFormPage(self.context.student,
     167            self.request, self.omit_fields)
     168        students_utils = getUtility(IStudentsUtils)
     169        return students_utils.renderPDF(
     170            self, 'clearance_invitation_slip',
     171            self.context.student, studentview,
     172            omit_fields=self.omit_fields,
     173            note=self.note)
    127174
    128175class StudyCourseCOEditFormPage(KofaEditFormPage):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r11773 r12121  
    3131from waeup.kofa.students.accommodation import BedTicket
    3232from waeup.kofa.testing import FunctionalTestCase
     33from waeup.kofa.browser.tests.test_pdf import samples_dir
    3334from waeup.kofa.interfaces import (
    3435    IExtFileStore, IFileStoreNameChooser)
     
    175176        self.assertTrue('Clearance has been requested'
    176177            in self.browser.contents)
     178        # Student can export physical_clearance.slip
     179        self.app['configuration'].name = u'University of Benin'
     180        self.student.physical_clearance_date = u'January 5th, 2015'
     181        self.browser.getLink("Clearance Data").click()
     182        self.browser.getLink("Download clearance invitation slip").click()
     183        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     184        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     185        path = os.path.join(samples_dir(), 'clearance_invitation_slip.pdf')
     186        open(path, 'wb').write(self.browser.contents)
     187        print "Sample PDF clearance_invitation_slip.pdf written to %s" % path
    177188
    178189    def test_manage_payments(self):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r11613 r12121  
    2121from waeup.kofa.browser.viewlets import ManageActionButton
    2222from waeup.uniben.students.interfaces import (
    23     ICustomStudentStudyCourse, ICustomStudentStudyLevel)
     23    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
     24    ICustomStudent, )
    2425from waeup.kofa.students.viewlets import (
    2526    FileDisplay, FileUpload, Image)
    2627from waeup.kofa.students.browser import (
    2728    ExportPDFClearanceSlipPage, StudyCourseDisplayFormPage,
    28     StudyLevelDisplayFormPage)
     29    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage)
    2930
    3031from kofacustom.nigeria.interfaces import MessageFactory as _
     
    5657    def target_url(self):
    5758        return self.view.url(self.view.context, self.target)
     59
     60
     61class ClearanceInvitationSlipActionButton(ManageActionButton):
     62    grok.order(5)
     63    grok.context(ICustomStudent)
     64    grok.view(StudentClearanceDisplayFormPage)
     65    grok.require('waeup.viewStudent')
     66    icon = 'actionicon_pdf.png'
     67    text = _('Download clearance invitation slip')
     68    target = 'clearance_invitation_slip.pdf'
     69
    5870
    5971# JAMB Letter
Note: See TracChangeset for help on using the changeset viewer.