Ignore:
Timestamp:
3 Jan 2023, 17:40:18 (23 months ago)
Author:
Henrik Bettermann
Message:

Add ExportPDFTishipSlip.

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

Legend:

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

    r17142 r17255  
    881881        return super(StudentMedicalHistoryEditFormPage, self).update()
    882882
     883
    883884class ExportPDFMedicalHistorySlip(grok.View):
    884885    """Deliver a PDF slip of the context.
     
    893894                   'adm_code', 'date_of_birth',
    894895                   'flash_notice', 'current_mode', 'entry_mode',
    895                    'entry_session', 'parents_email', 'study_course',
     896                   'entry_session', 'parents_email',
    896897                   'current_level', 'reg_number', 'sex',
    897898                   'certificate')
     
    919920            omit_fields=self.omit_fields,)
    920921
     922class ExportPDFTishipSlip(grok.View):
     923    """Deliver a PDF slip of the context.
     924    """
     925    grok.context(ICustomStudent)
     926    grok.name('tiship_slip.pdf')
     927    grok.require('waeup.viewStudent')
     928    prefix = 'form'
     929    form_fields = grok.AutoFields(IMedicalHistory).select(
     930        'genotype', 'bloodgroup')
     931    title = ''
     932
     933    omit_fields = ('password', 'suspended', 'suspended_comment',
     934                   'adm_code',
     935                   'flash_notice', 'current_mode', 'entry_mode',
     936                   'parents_email',
     937                   )
     938
     939    @property
     940    def label(self):
     941        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     942        return translate(_('TISHIP Registration Slip of'),
     943            'waeup.kofa', target_language=portal_language) \
     944            + ' %s' % self.context.display_fullname
     945
     946
     947    def _sigsInFooter(self):
     948        return (_('Year of Graduation'),
     949                    _('Signature'),
     950                    _('Date'),
     951                    )
     952
     953    def render(self):
     954        studentview = StudentBasePDFFormPage(self.context.student,
     955            self.request, self.omit_fields)
     956        students_utils = getUtility(IStudentsUtils)
     957        return students_utils.renderPDF(
     958            self, 'tiship_slip.pdf',
     959            self.context.student, studentview,
     960            sigs_in_footer=self._sigsInFooter(),
     961            omit_fields=self.omit_fields,)
     962
    921963class PlagTestInfoPage(KofaPage):
    922964    "Landing page after plagiation test payment"
  • main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py

    r16509 r17255  
    215215        )
    216216
     217
     218    # Tiship form
     219
     220    genotype = schema.TextLine(
     221        title = _(u'Genotype'),
     222        required = False,
     223        )
     224
     225    bloodgroup = schema.TextLine(
     226        title = _(u'Blood Group'),
     227        required = False,
     228        )
     229
    217230class ICustomStudentPersonal(INigeriaStudentPersonal):
    218231    """Student personal data.
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r17111 r17255  
    12201220        open(path, 'wb').write(self.browser.contents)
    12211221        print "Sample PDF medical_questionnaire_slip.pdf written to %s" % path
     1222
     1223        self.browser.open(self.student_path)
     1224        self.browser.getLink("Medical Questionnaire").click()
     1225        self.browser.getControl(name="form.bloodgroup").value = 'A'
     1226        self.browser.getControl(name="form.genotype").value = 'XYZ'
     1227        self.browser.getControl("Save").click()
     1228        self.browser.getLink("Download TISHIP registration slip").click()
     1229        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1230        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1231        path = os.path.join(samples_dir(), 'tiship_slip.pdf')
     1232        open(path, 'wb').write(self.browser.contents)
     1233        print "Sample PDF tiship_slip.pdf written to %s" % path
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_export.py

    r16437 r17255  
    1 import datetime
     1    import datetime
    22from zope.component import queryUtility
    33from zope.interface.verify import verifyObject, verifyClass
     
    141141        result = open(self.outfile, 'rb').read()
    142142        self.assertMatches(
    143             'asthma,body_pains,breathing,catarrh,company_confirmed,'
    144             'company_suspected,cough,diabetes,fever,headaches,hypertension,'
     143            'asthma,bloodgroup,body_pains,breathing,catarrh,company_confirmed,'
     144            'company_suspected,cough,diabetes,fever,genotype,headaches,hypertension,'
    145145            'lagos_abuja,medical_updated,medicines,negative,obesity,'
    146146            'others,outside,positive,smell,sneezing,sore_throat,taste,'
     
    148148            'matric_number,faccode,depcode,state,current_session,'
    149149            'current_level\r\n'
    150             ',,,,,,,,,,,,,,,,,,,,,1,,,,A111111,Anna M. Tester,234,'
     150            ',,,,,,,,,,,,,,,,,,,,,,,1,,,,A111111,Anna M. Tester,234,'
    151151            'NA,NA,created,2012,200\r\n' , result
    152152            )
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r17236 r17255  
    4949        'form.lagos_abuja': _(u'Travel History'),
    5050        'form.company_suspected': _(u'History of Contact/Infection'),
     51        'form.genotype': _(u'TISHIP Registration Form Data'),
    5152        }
    5253
     
    9495        if not student.state in acc_details['allowed_states']:
    9596            return _("You are in the wrong registration state.")
    96         if student['studycourse'].current_session != acc_details[
    97             'booking_session']:
    98             return _('Your current session does not '
    99                      'match accommodation session.')
     97        #if student['studycourse'].current_session != acc_details[
     98        #    'booking_session']:
     99        #    return _('Your current session does not '
     100        #             'match accommodation session.')
     101        if  acc_details['booking_session'] - student[
     102            'studycourse'].current_session > self.ACCOMMODATION_SPAN:
     103            return _('Your current session does not allow ' + \
     104                    'to book accommodation.')
    100105        stage = bt.split('_')[2]
    101106        if not student.is_postgrad and stage != 'fr' and not student[
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r17145 r17255  
    206206    target = 'medical_questionnaire_slip.pdf'
    207207
     208class TishipSlipActionButton(ManageActionButton):
     209    grok.order(2)
     210    grok.context(ICustomStudent)
     211    grok.view(StudentMedicalHistoryEditFormPage)
     212    grok.require('waeup.viewStudent')
     213    icon = 'actionicon_pdf.png'
     214    text = _('Download TISHIP registration slip')
     215    target = 'tiship_slip.pdf'
     216
    208217class PlagTestLinkActionButton(ManageActionButton):
    209218    grok.order(10) 
Note: See TracChangeset for help on using the changeset viewer.