Changeset 14834


Ignore:
Timestamp:
4 Sep 2017, 07:37:44 (7 years ago)
Author:
Henrik Bettermann
Message:

Add JUPEB result slip (first draft).

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

    r14689 r14834  
    283283            note=self.note)
    284284
     285class ExportJUPEBResultSlip(ExportExaminationScheduleSlip):
     286    """Deliver a JUPEB result slip.
     287
     288    This form page is available only in Uniben.
     289    """
     290
     291    grok.name('jupeb_result_slip.pdf')
     292    label = u'JUPEB Result Slip'
     293
     294    @property
     295    def note(self):
     296        return """
     297<br /><br /><br /><br /><font size='12'>
     298Your JUPEB results are as follows:
     299<br /><br />
     300<strong>%s</strong>
     301</font>
     302<br /><br /><br /><br />
     303<font size='8'>
     304Key: A = 5, B = 4, C = 3, D = 2, E = 1, F = 0, X = Absent, Q = Cancelled
     305</font>
     306
     307""" % self.context.flash_notice
     308        return
     309
     310    def update(self):
     311        if not self.context.flash_notice or self.context.faccode != 'JUPEB':
     312            self.flash(_('Forbidden'), type="warning")
     313            self.redirect(self.url(self.context))
     314
    285315class CustomStudentPersonalDisplayFormPage(
    286316    NigeriaStudentPersonalDisplayFormPage):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r14588 r14834  
    3131from waeup.kofa.authentication import LocalRoleSetEvent
    3232from waeup.kofa.app import University
     33from waeup.kofa.university.faculty import Faculty
     34from waeup.kofa.university.department import Department
    3335from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    3436from waeup.kofa.students.accommodation import BedTicket
     
    211213        self.browser.open(self.student_path)
    212214        self.assertFalse('examination schedule slip' in self.browser.contents)
     215
     216    def test_jupeb_result_slip(self):
     217        self.student.flash_notice = u'My JUPEB results'
     218        self.browser.open(self.login_path)
     219        self.browser.getControl(name="form.login").value = self.student_id
     220        self.browser.getControl(name="form.password").value = 'spwd'
     221        self.browser.getControl("Login").click()
     222        self.assertFalse('JUPEB result slip' in self.browser.contents)
     223        # Create JUPEB faculty
     224        cert = createObject('waeup.Certificate')
     225        cert.code = u'xyz'
     226        self.app['faculties']['JUPEB'] = Faculty(code=u'JUPEB')
     227        self.app['faculties']['JUPEB']['dep1'] = Department(code=u'dep1')
     228        self.app['faculties']['JUPEB']['dep1'].certificates.addCertificate(cert)
     229        self.student['studycourse'].certificate = cert
     230        self.browser.open(self.student_path)
     231        self.browser.getLink("Download JUPEB result slip").click()
     232        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     233        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     234        path = os.path.join(samples_dir(), 'jupeb_result_slip.pdf')
     235        open(path, 'wb').write(self.browser.contents)
     236        print "Sample PDF jupeb_result_slip.pdf written to %s" % path
     237        self.student.flash_notice = u''
     238        self.browser.open(self.student_path)
     239        self.assertFalse('JUPEB result slip' in self.browser.contents)
    213240
    214241    def test_manage_payments(self):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r13723 r14834  
    111111        return False
    112112
     113class JUPEBResultSlipActionButton(ManageActionButton):
     114    grok.order(11)
     115    grok.context(ICustomStudent)
     116    grok.view(StudentBaseDisplayFormPage)
     117    grok.require('waeup.viewStudent')
     118    icon = 'actionicon_pdf.png'
     119    text = _('Download JUPEB result slip')
     120    target = 'jupeb_result_slip.pdf'
     121
     122    @property
     123    def target_url(self):
     124        if self.context.flash_notice and self.context.faccode == 'JUPEB':
     125            return self.view.url(self.view.context, self.target)
     126        return False
     127
    113128# JAMB Letter
    114129
Note: See TracChangeset for help on using the changeset viewer.