Ignore:
Timestamp:
12 Oct 2018, 15:51:59 (6 years ago)
Author:
Henrik Bettermann
Message:

Add MedicalLaboratoryRequestForm?.

Location:
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/browser.py

    r15177 r15185  
    206206            self.context.student, omit_fields=self.omit_fields,
    207207            pre_text=pre_text, post_text='')
     208
     209class MedicalLaboratoryRequestForm(UtilityView, grok.View):
     210    """Deliver a PDF notification slip.
     211    """
     212    grok.context(ICustomStudent)
     213    grok.name('medical_laboratory_form.pdf')
     214    grok.require('waeup.viewStudent')
     215    prefix = 'form'
     216
     217    form_fields = grok.AutoFields(ICustomStudent).select(
     218        'student_id', 'matric_number', 'sex', 'email', 'phone', 'perm_address')
     219    omit_fields = ('current_mode')
     220
     221    label = u'Student\'s Medical Laboratory Request Form'
     222    title = u'Student\'s Medical Laboratory Request Form'
     223
     224    post_text = """
     225
     226Laboratory request: Student's Medical Test
     227
     228Lab Results/Status:
     229
     230Medical Laboratory Scientist's Sign.:
     231
     232
     233
     234Notice to all newly admitted students:
     235
     2361. Carry out your mandatory medical laboratory tests at:
     237(a) the Edo State Polyechnic Health Centre
     2382. Evidence of medical screening payment and the downloaded student's laboratory test request form are required for the medical tests to be conducted for students.
     2393. Collect your lab tests results and upload during clearance process online.
     2404. Students' admission records and clearance are incomplete without medical test result.
     2415. Results of medical tests from elsewhere are not accepted.
     2426. Medical tests are conducted only within admission period, and will end in matriculation week. Unnecessary delays will not be allowed.
     2437. This information applies to both full- time and part-time.
     244"""
     245
     246    def render(self):
     247        if not self.context.medical_fee_paid:
     248            self.flash('Not allowed.', type="danger")
     249            self.redirect(self.url(self.context))
     250            return
     251        students_utils = getUtility(IStudentsUtils)
     252        return students_utils.renderPDFAdmissionLetter(self,
     253            self.context.student, omit_fields=self.omit_fields,
     254            pre_text='', post_text=self.post_text)
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/student.py

    r15000 r15185  
    4343        return False
    4444
     45    @property
     46    def medical_fee_paid(self):
     47        for key in self['payments'].keys():
     48            ticket = self['payments'][key]
     49            if ticket.p_state == 'paid' and \
     50                ticket.p_session == self.current_session and \
     51                ticket.p_category == 'medical':
     52                return True
     53        return False
    4554
    4655# Set all attributes of Student required in IStudent as field
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/tests/test_browser.py

    r15000 r15185  
    2121from StringIO import StringIO
    2222from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
     23from mechanize import LinkNotFoundError
    2324from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2425from zope.component.hooks import setSite, clearSite
     
    3435    IExtFileStore, IFileStoreNameChooser)
    3536from waeup.kofa.students.interfaces import IStudentsUtils
     37from waeup.kofa.browser.tests.test_pdf import samples_dir
    3638from kofacustom.edopoly.testing import FunctionalLayer
    3739
     
    4446    def test_dummytest(self):
    4547        return
     48
     49class StudentUITests(StudentsFullSetup):
     50    """Tests for customized student class views and pages
     51    """
     52
     53    layer = FunctionalLayer
     54
     55    def setUp(self):
     56        super(StudentUITests, self).setUp()
     57
     58
     59    def test_medical_laboratory_form(self):
     60        self.browser.open(self.login_path)
     61        self.browser.getControl(name="form.login").value = self.student_id
     62        self.browser.getControl(name="form.password").value = 'spwd'
     63        self.browser.getControl("Login").click()
     64        self.assertRaises(
     65            LinkNotFoundError,
     66            self.browser.getLink, 'Download medical laboratory request form')
     67        # Add medical fee payment ticket
     68        self.app['configuration']['2004'].medical = 180.0
     69        payment = createObject('waeup.StudentOnlinePayment')
     70        payment.p_category = u'medical'
     71        payment.p_session = self.student.current_session
     72        payment.p_id = u'anyid'
     73        payment.p_state = u'paid'
     74        self.student['payments']['anykey'] = payment
     75        self.browser.open(self.student_path)
     76        self.browser.getLink("Download medical laboratory request form").click()
     77        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     78        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     79        path = os.path.join(samples_dir(), 'medical_laboratory_form.pdf')
     80        open(path, 'wb').write(self.browser.contents)
     81        print "Sample PDF medical_laboratory_form.pdf written to %s" % path
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/viewlets.py

    r15177 r15185  
    6969            return ''
    7070        return self.view.url(self.view.context, self.target)
     71
     72class MedicalLaboratoryRequestFormActionButton(ManageActionButton):
     73    grok.order(11)
     74    grok.context(IStudent)
     75    grok.view(StudentBaseDisplayFormPage)
     76    grok.require('waeup.viewStudent')
     77    icon = 'actionicon_pdf.png'
     78    text = _('Download medical laboratory request form')
     79    target = 'medical_laboratory_form.pdf'
     80
     81    @property
     82    def target_url(self):
     83        if not self.context.medical_fee_paid:
     84            return ''
     85        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.