Changeset 17542 for main


Ignore:
Timestamp:
16 Aug 2023, 09:24:29 (17 months ago)
Author:
Henrik Bettermann
Message:

Implement medical examination form.

Location:
main/waeup.uniben/trunk/src/waeup/uniben
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/hostels/tests.py

    r15251 r17542  
    4747        self.student['accommodation'].addBedTicket(bedticket)
    4848        self.app[
    49             'hostels']['hall-x']['hall_block_room_bed'].owner = self.student_id
     49            'hostels']['hall-x']['hall-x_block_room_bed'].owner = self.student_id
    5050        notify(grok.ObjectModifiedEvent(
    51             self.app['hostels']['hall-x']['hall_block_room_bed']))
     51            self.app['hostels']['hall-x']['hall-x_block_room_bed']))
    5252        results = cat.searchResults(owner=(self.student_id, self.student_id))
    5353        self.assertEqual(len(results), 1)
     
    5858        self.browser.open(self.container_path + '/releaseexpired')
    5959        self.assertTrue(
    60             'Successfully released beds: hall_block_room_bed (B1000000)'
     60            'Successfully released beds: hall-x_block_room_bed (B1000000)'
    6161            in self.browser.contents)
    6262        results = cat.searchResults(owner=(self.student_id, self.student_id))
     
    6565            '-- booking expired (2015-10-14 08:35:38 WAT) --')
    6666        self.assertEqual(
    67             self.app['hostels']['hall-x']['hall_block_room_bed'].owner,
     67            self.app['hostels']['hall-x']['hall-x_block_room_bed'].owner,
    6868            NOT_OCCUPIED)
    6969        # Releasing is logged.
     
    7171        self.assertTrue(
    7272            'hostels.browser.ReleaseExpiredAllocationsPage - hostels - '
    73             'released: hall_block_room_bed (B1000000)'
     73            'released: hall-x_block_room_bed (B1000000)'
    7474            in logcontent)
    7575        return
  • main/waeup.uniben/trunk/src/waeup/uniben/interfaces.py

    r17301 r17542  
    142142        )
    143143
     144    medical_clearance_fee = schema.Float(
     145        title = _(u'Medical Clearance Fee'),
     146        default = 0.0,
     147        required = False,
     148        )
     149
    144150    remita_enabled = schema.Bool(
    145151        title = _(u'Remita integration enabled'),
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r17395 r17542  
    263263Dear %s,
    264264<br /><br /><br />
    265 You are invited for your physical clearance on:
     265You are invited for your Health Centre clearance on:
    266266<br /><br />
    267267<strong>%s</strong>.
    268268<br /><br />
    269 Please bring along this letter of invitation to the University Main Auditorium
    270 <br /><br />
    271 on your clearance date.
     269Please bring along your downloaded Health Centre Form to the University Health Centre
     270on your Health Centre clearance date.
    272271<br /><br /><br />
    273272Signed,
     
    295294            omit_fields=self.omit_fields,
    296295            note=self.note)
     296
     297class ExportMedicalExaminationSlip(UtilityView, grok.View):
     298    """Deliver an .
     299
     300    This form page is available only in Uniben.
     301    """
     302    grok.context(ICustomStudent)
     303    grok.name('medical_examination_slip.pdf')
     304    grok.require('waeup.viewStudent')
     305    prefix = 'form'
     306
     307    label = u'Uniben Medical Examination Form'
     308
     309    omit_fields = (
     310        'suspended',
     311        'adm_code', 'suspended_comment',
     312        'current_level',
     313        'department', 'current_mode',
     314        'entry_session', 'matric_number',
     315        'flash_notice', 'parents_email',
     316        'faculty', 'department')
     317
     318    form_fields = grok.AutoFields(ICustomStudentPersonal).select(
     319        'marit_stat', 'perm_address', 'next_kin_phone')
     320    form_fields['perm_address'].custom_widget = BytesDisplayWidget
     321
     322    def _medicalClearancePaymentMade(self, student, session):
     323        if len(student['payments']):
     324            for ticket in student['payments'].values():
     325                if ticket.p_state == 'paid' and \
     326                    ticket.p_category == 'medical_clearance' and \
     327                    ticket.p_session == session:
     328                    return True
     329        return False
     330
     331    def update(self):
     332        if self.context.student.state != CLEARED \
     333            or not  self.context.student.physical_clearance_date:
     334            self.flash(_('Forbidden'), type="warning")
     335            self.redirect(self.url(self.context))
     336        if not self._medicalClearancePaymentMade(
     337            self.context, self.context.current_session):
     338            self.flash('Please pay medical clearance fee first.',
     339                type="warning")
     340            self.redirect(self.url(self.context))
     341        return
     342
     343    def render(self):
     344        studentview = StudentBasePDFFormPage(self.context.student,
     345            self.request, self.omit_fields)
     346        students_utils = getUtility(IStudentsUtils)
     347        file_path = os.path.join(
     348            os.path.dirname(__file__), 'static', 'medical_examination_form.pdf')
     349        file = open(file_path, 'rb')
     350        mergefiles = [file,]
     351        return students_utils.renderPDF(
     352            self, 'medical_examination_slip',
     353            self.context.student, studentview,
     354            omit_fields=self.omit_fields,
     355            mergefiles=mergefiles,
     356            )
     357
    297358
    298359class ExportExaminationScheduleSlip(UtilityView, grok.View):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r17457 r17542  
    230230        self.assertTrue('Clearance has been requested'
    231231            in self.browser.contents)
    232         # Now student can export physical_clearance.slip
     232        # Now student can export physical_clearance_slip
    233233        self.app['configuration'].name = u'University of Benin'
    234234        self.student.physical_clearance_date = u'January 5th, 2015'
     
    240240        open(path, 'wb').write(self.browser.contents)
    241241        print "Sample PDF clearance_invitation_slip.pdf written to %s" % path
     242
     243    def test_medical_examination_slip(self):
     244        # Student can export medical_examination_slip
     245        self.app['configuration']['2004'].medical_clearance_fee = 1000.0
     246        self.app['configuration'].name = u'University of Benin'
     247        IWorkflowState(self.student).setState('cleared')
     248        self.student.perm_address = u'My Address in Nigeria'
     249        self.student.physical_clearance_date = u'January 5th, 2015'
     250        self.browser.open(self.login_path)
     251        self.browser.getControl(name="form.login").value = self.student_id
     252        self.browser.getControl(name="form.password").value = 'spwd'
     253        self.browser.getControl("Login").click()
     254        self.browser.open(self.clearance_path)
     255        self.browser.getLink("Download medical examination slip").click()
     256        self.assertTrue('Please pay medical clearance fee first' in
     257            self.browser.contents)
     258        self.browser.open(self.payments_path)
     259        self.browser.getLink("Add current session payment ticket").click()
     260        self.browser.getControl(name="form.p_category").value = ['medical_clearance']
     261        self.browser.getControl("Create ticket").click()
     262        p_ticket = self.student['payments'].values()[0]
     263        p_ticket.approveStudentPayment()
     264        self.browser.open(self.clearance_path)
     265        self.browser.getLink("Download medical examination slip").click()
     266        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     267        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     268        path = os.path.join(samples_dir(), 'medical_examination_slip.pdf')
     269        open(path, 'wb').write(self.browser.contents)
     270        print "Sample PDF medical_examination_slip.pdf written to %s" % path
     271
    242272        # Students can open the personal edit page and see the parent_email field.
    243273        self.browser.open(self.student_path + '/edit_personal')
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r17395 r17542  
    1919import grok
    2020from zope.component import getUtility
    21 from waeup.kofa.interfaces import REQUESTED, REGISTERED, IExtFileStore
     21from waeup.kofa.interfaces import REQUESTED, REGISTERED, CLEARED, IExtFileStore
    2222from waeup.kofa.browser.viewlets import ManageActionButton
    2323from waeup.kofa.students.interfaces import IStudentsUtils
     
    136136        return False
    137137
     138class MadicalExaminationSlipActionButton(ManageActionButton):
     139    grok.order(6)
     140    grok.context(ICustomStudent)
     141    grok.view(StudentClearanceDisplayFormPage)
     142    grok.require('waeup.viewStudent')
     143    icon = 'actionicon_pdf.png'
     144    text = _('Download medical examination slip')
     145    target = 'medical_examination_slip.pdf'
     146
     147    @property
     148    def target_url(self):
     149        if self.context.student.state == CLEARED \
     150            and self.context.student.physical_clearance_date:
     151            return self.view.url(self.view.context, self.target)
     152        return False
     153
    138154class ExaminationScheduleSlipActionButton(ManageActionButton):
    139155    grok.order(10)
  • main/waeup.uniben/trunk/src/waeup/uniben/utils/utils.py

    r17401 r17542  
    9595        'plag_test':'Final Year Plagiarism Test',
    9696        'flc_modules': 'FLC Modules Fee',
     97        'medical_clearance': 'Medical Clearance Fee',
    9798        }
    9899
     
    118119        'plag_test':'Final Year Plagiarism Test (for final year project or PG thesis)',
    119120        'flc_modules': 'FLC Modules Fee',
     121        'medical_clearance': 'Medical Clearance Fee',
    120122        }
    121123
Note: See TracChangeset for help on using the changeset viewer.