Changeset 16385


Ignore:
Timestamp:
25 Jan 2021, 12:37:04 (4 years ago)
Author:
Henrik Bettermann
Message:

Adjust form and buttons.

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

Legend:

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

    r16383 r16385  
    780780        return
    781781
     782
     783
     784
     785from zope.schema.vocabulary import SimpleVocabulary
     786from zope.formlib.itemswidgets import RadioWidget
     787from zope.formlib.itemswidgets import SelectWidget, DropdownWidget
     788
     789def CustomBooleanRadioWidget(field, request, true=_('yes'), false=_('no')):
     790    vocabulary = SimpleVocabulary.fromItems( ((true, True), (false, False)) )
     791    widget = RadioWidget(field, vocabulary, request)
     792    widget.required = False
     793    return widget
     794
    782795class StudentMedicalHistoryEditFormPage(KofaEditFormPage):
    783796    """ Page to edit medical data
     
    786799    grok.name('edit_medical')
    787800    grok.require('waeup.handleStudent')
    788     form_fields = grok.AutoFields(IMedicalHistory)
    789     form_fields['medical_updated'].for_display = True
    790     form_fields[
    791         'medical_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    792     label = _('Edit medical history data')
     801    label = _('Medical Questionnaire')
    793802    pnav = 4
     803
     804    @property
     805    def form_fields(self):
     806        form_fields = grok.AutoFields(IMedicalHistory)
     807        form_fields['medical_updated'].for_display = True
     808        for field in ('fever', 'headaches', 'catarrh', 'cough', 'sore_throat',
     809                      'breathing', 'sneezing', 'weakness', 'body_pains',
     810                      'smell', 'taste', 'asthma', 'hypertension', 'diabetes',
     811                      'obesity', 'lagos_abuja', 'outside', 'company_suspected',
     812                      'company_confirmed', 'positive', 'negative',
     813                      'vaccination'):
     814            form_fields[field].custom_widget = CustomBooleanRadioWidget
     815        return form_fields
    794816
    795817    @property
     
    808830    grok.name('manage_medical')
    809831    grok.require('waeup.manageStudent')
    810     label = _('Manage medical history data')
     832    label = _('Manage medical questionnaire data')
    811833
    812834class ExportPDFMedicalHistorySlip(grok.View):
     
    814836    """
    815837    grok.context(ICustomStudent)
    816     grok.name('medical_history_slip.pdf')
     838    grok.name('medical_questionnaire_slip.pdf')
    817839    grok.require('waeup.viewStudent')
    818840    prefix = 'form'
     
    829851    def title(self):
    830852        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    831         return translate(_('Medical History Questionnaire'), 'waeup.kofa',
     853        return translate(_('Medical Questionnaire'), 'waeup.kofa',
    832854            target_language=portal_language)
    833855
     
    835857    def label(self):
    836858        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    837         return translate(_('Medical History Slip of'),
     859        return translate(_('Medical Questionnaire Slip of'),
    838860            'waeup.kofa', target_language=portal_language) \
    839861            + ' %s' % self.context.display_fullname
     
    844866        students_utils = getUtility(IStudentsUtils)
    845867        return students_utils.renderPDF(
    846             self, 'medical_history_slip.pdf',
     868            self, 'medical_questionnaire_slip.pdf',
    847869            self.context.student, studentview,
    848870            omit_fields=self.omit_fields,)
  • main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py

    r16382 r16385  
    6666        title = _(u'Fever'),
    6767        default = False,
    68         required = False,
     68        required = True,
    6969        )
    7070
     
    7272        title = _(u'Headaches'),
    7373        default = False,
    74         required = False,
     74        required = True,
    7575        )
    7676
     
    7878        title = _(u'Catarrh'),
    7979        default = False,
    80         required = False,
     80        required = True,
    8181        )
    8282
     
    8484        title = _(u'Cough'),
    8585        default = False,
    86         required = False,
     86        required = True,
    8787        )
    8888
     
    9090        title = _(u'Sore throat'),
    9191        default = False,
    92         required = False,
     92        required = True,
    9393        )
    9494
     
    9696        title = _(u'Difficulty with breathing'),
    9797        default = False,
    98         required = False,
     98        required = True,
    9999        )
    100100
     
    102102        title = _(u'Sneezing'),
    103103        default = False,
    104         required = False,
     104        required = True,
    105105        )
    106106
     
    108108        title = _(u'Weakness/tiredness'),
    109109        default = False,
    110         required = False,
     110        required = True,
    111111        )
    112112
     
    114114        title = _(u'Body pains'),
    115115        default = False,
    116         required = False,
     116        required = True,
    117117        )
    118118
     
    120120        title = _(u'Loss of smell (inability to smell)'),
    121121        default = False,
    122         required = False,
     122        required = True,
    123123        )
    124124
     
    126126        title = _(u'Loss of taste'),
    127127        default = False,
    128         required = False,
     128        required = True,
    129129        )
    130130
     
    134134        title = _(u'Asthma'),
    135135        default = False,
    136         required = False,
     136        required = True,
    137137        )
    138138
     
    140140        title = _(u'Hypertension'),
    141141        default = False,
    142         required = False,
     142        required = True,
    143143        )
    144144
     
    146146        title = _(u'Diabetes'),
    147147        default = False,
    148         required = False,
     148        required = True,
    149149        )
    150150
     
    152152        title = _(u'Obesity'),
    153153        default = False,
    154         required = False,
     154        required = True,
    155155        )
    156156
     
    170170        title = _(u'Have you travelled to Lagos or Abuja in the last two weeks?'),
    171171        default = False,
    172         required = False,
     172        required = True,
    173173        )
    174174
     
    176176        title = _(u'Have you travelled outside the country in the last 4 weeks?'),
    177177        default = False,
    178         required = False,
     178        required = True,
    179179        )
    180180
     
    184184        title = _(u'Were you in the company of a suspected case of COVID 19 in the last two weeks?'),
    185185        default = False,
    186         required = False,
     186        required = True,
    187187        )
    188188
     
    190190        title = _(u'Were you in the company of a confirmed case of COVID 19 in the last two weeks?'),
    191191        default = False,
    192         required = False,
     192        required = True,
    193193        )
    194194
     
    196196        title = _(u'Have you had a positive COVID 19 test done?'),
    197197        default = False,
    198         required = False,
     198        required = True,
    199199        )
    200200
     
    202202        title = _(u'Have you had a negative COVID 19 test done?'),
    203203        default = False,
    204         required = False,
     204        required = True,
    205205        )
    206206
     
    208208        title = _(u'Have you had COVID 19 vaccination?'),
    209209        default = False,
    210         required = False,
     210        required = True,
    211211        )
    212212
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r16382 r16385  
    11691169                           self.browser.contents)
    11701170
    1171     def test_student_medical_history(self):
     1171    def test_student_medical_questionnaire(self):
    11721172        IWorkflowInfo(self.student).fireTransition('admit')
    11731173        self.browser.open(self.login_path)
     
    11781178            '...You logged in...', self.browser.contents)
    11791179        self.browser.getLink("Base Data").click()
    1180         self.browser.getLink("Edit medical history").click()
    1181         self.browser.getLink("Download medical history slip").click()
     1180        self.browser.getLink("Medical Questionnaire").click()
     1181        self.browser.getLink("Download medical questionnaire slip").click()
    11821182        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    11831183        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    1184         path = os.path.join(samples_dir(), 'medical_history_slip.pdf')
     1184        path = os.path.join(samples_dir(), 'medical_questionnaire_slip.pdf')
    11851185        open(path, 'wb').write(self.browser.contents)
    1186         print "Sample PDF medical_history_slip.pdf written to %s" % path
     1186        print "Sample PDF medical_questionnaire_slip.pdf written to %s" % path
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r16383 r16385  
    185185    grok.view(StudentBaseDisplayFormPage)
    186186    grok.require('waeup.handleStudent')
    187     text = _('Edit medical history')
     187    text = _('Medical Questionnaire')
    188188    target = 'edit_medical'
    189189    icon = 'actionicon_medical.png'
     
    200200    grok.require('waeup.viewStudent')
    201201    icon = 'actionicon_pdf.png'
    202     text = _('Download medical history slip')
    203     target = 'medical_history_slip.pdf'
     202    text = _('Download medical questionnaire slip')
     203    target = 'medical_questionnaire_slip.pdf'
    204204
    205205# JAMB Letter
Note: See TracChangeset for help on using the changeset viewer.