Changeset 13723


Ignore:
Timestamp:
23 Feb 2016, 17:36:46 (9 years ago)
Author:
Henrik Bettermann
Message:

Add exam schedule examination slip.

Fix test.

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

    r13719 r13723  
    232232            note=self.note)
    233233
     234class ExportExaminationScheduleSlip(UtilityView, grok.View):
     235    """Deliver a examination schedule slip.
     236
     237    This form page is available only in Uniben.
     238    """
     239    grok.context(ICustomStudent)
     240    grok.name('examination_schedule_slip.pdf')
     241    grok.require('waeup.viewStudent')
     242    prefix = 'form'
     243
     244    label = u'Examination Schedule Slip'
     245
     246    omit_fields = (
     247        'suspended', 'phone', 'email',
     248        'adm_code', 'suspended_comment',
     249        'date_of_birth', 'current_level',
     250        'current_mode',
     251        'entry_session',
     252        'flash_notice')
     253
     254    form_fields = []
     255
     256    @property
     257    def note(self):
     258        return """
     259<br /><br /><br /><br /><font size='12'>
     260Your examination date, time and venue is scheduled as follows:
     261<br /><br />
     262<strong>%s</strong>
     263</font>
     264
     265""" % self.context.flash_notice
     266        return
     267
     268
     269    def update(self):
     270        if not self.context.flash_notice \
     271            or not 'exam' in self.context.flash_notice.lower():
     272            self.flash(_('Forbidden'), type="warning")
     273            self.redirect(self.url(self.context))
     274
     275    def render(self):
     276        studentview = StudentBasePDFFormPage(self.context.student,
     277            self.request, self.omit_fields)
     278        students_utils = getUtility(IStudentsUtils)
     279        return students_utils.renderPDF(
     280            self, 'examination_schedule_slip',
     281            self.context.student, studentview,
     282            omit_fields=self.omit_fields,
     283            note=self.note)
     284
    234285class CustomStudentPersonalDisplayFormPage(
    235286    NigeriaStudentPersonalDisplayFormPage):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r13621 r13723  
    194194        self.browser.open(self.student_path + '/edit_personal')
    195195        self.assertTrue('parent_email' in self.browser.contents)
     196
     197    def test_examination_schedule_slip(self):
     198        self.student.flash_notice = u'My Examination Date'
     199        self.browser.open(self.login_path)
     200        self.browser.getControl(name="form.login").value = self.student_id
     201        self.browser.getControl(name="form.password").value = 'spwd'
     202        self.browser.getControl("Login").click()
     203        self.browser.getLink("Download examination schedule slip").click()
     204        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     205        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     206        path = os.path.join(samples_dir(), 'examination_schedule_slip.pdf')
     207        open(path, 'wb').write(self.browser.contents)
     208        print "Sample PDF examination_schedule_slip.pdf written to %s" % path
     209        # If flash_notive does not contain exam' the button does not show up.
     210        self.student.flash_notice = u'anything'
     211        self.browser.open(self.student_path)
     212        self.assertFalse('examination schedule slip' in self.browser.contents)
    196213
    197214    def test_manage_payments(self):
     
    929946        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
    930947        self.browser.getControl("Create ticket").click()
    931         ctrl = self.browser.getControl(name='val_id')
    932         value = ctrl.options[0]
    933         self.browser.getLink(value).click()
    934948        p_ticket = self.student['payments'].values()[0]
    935949        p_ticket.approveStudentPayment()
     
    10291043        self.assertMatches('...Payment ticket created...',
    10301044                           self.browser.contents)
    1031         ctrl = self.browser.getControl(name='val_id')
    1032         value = ctrl.options[0]
    10331045        # Maintennace fee is taken from the hostel object.
    1034         self.assertEqual(self.student['payments'][value].amount_auth, 876.0)
     1046        self.assertEqual(self.student['payments'].values()[1].amount_auth, 876.0)
    10351047        # If the hostel's maintenance fee isn't set, the fee is
    10361048        # taken from the session configuration object.
     
    10391051        self.browser.getControl(name="form.p_category").value = ['hostel_maintenance']
    10401052        self.browser.getControl("Create ticket").click()
    1041         ctrl = self.browser.getControl(name='val_id')
    1042         value = ctrl.options[1]
    1043         self.assertEqual(self.student['payments'][value].amount_auth, 987.0)
     1053        self.assertEqual(self.student['payments'].values()[2].amount_auth, 987.0)
    10441054        return
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r13063 r13723  
    2424    ICustomStudent, )
    2525from waeup.kofa.students.fileviewlets import (
    26     StudentFileDisplay, StudentFileUpload, StudentImage)
     26    StudentFileDisplay, StudentFileUpload, StudentImage,)
    2727from waeup.kofa.students.browser import (
    2828    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
    29     StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage)
     29    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage,
     30    StudentBaseDisplayFormPage)
    3031
    3132from kofacustom.nigeria.interfaces import MessageFactory as _
     
    9495        return False
    9596
     97class ExaminationScheduleSlipActionButton(ManageActionButton):
     98    grok.order(10)
     99    grok.context(ICustomStudent)
     100    grok.view(StudentBaseDisplayFormPage)
     101    grok.require('waeup.viewStudent')
     102    icon = 'actionicon_pdf.png'
     103    text = _('Download examination schedule slip')
     104    target = 'examination_schedule_slip.pdf'
     105
     106    @property
     107    def target_url(self):
     108        if self.context.flash_notice \
     109            and 'exam' in self.context.flash_notice.lower():
     110            return self.view.url(self.view.context, self.target)
     111        return False
    96112
    97113# JAMB Letter
Note: See TracChangeset for help on using the changeset viewer.