Changeset 16390


Ignore:
Timestamp:
29 Jan 2021, 11:03:57 (4 years ago)
Author:
Henrik Bettermann
Message:

Implement MedicalHistoryExporter?.

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

Legend:

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

    r15048 r16390  
    1818"""Exporters for student related stuff.
    1919"""
     20import grok
    2021from datetime import datetime
    2122from waeup.uniben.students.interfaces import (
     
    2425    ICustomStudentStudyLevel,
    2526    ICustomCourseTicket,
    26     ICustomStudentOnlinePayment)
     27    ICustomStudentOnlinePayment,
     28    IMedicalHistory)
    2729from kofacustom.nigeria.students.export import (
    2830    NigeriaStudentExporter,
     
    3335    NigeriaDataForBursaryExporter,
    3436    )
    35 from waeup.kofa.students.export import SchoolFeePaymentsOverviewExporter
     37from waeup.kofa.students.export import (
     38    SchoolFeePaymentsOverviewExporter, StudentExporterBase)
    3639from waeup.kofa.utils.helpers import iface_names
    3740
     
    103106        'entry_session', 'reg_number'
    104107        ) + year_range_tuple
     108
     109class MedicalHistoryExporter(grok.GlobalUtility, StudentExporterBase):
     110    """
     111    """
     112    grok.name('medicalhistory')
     113
     114    fields = tuple(
     115        sorted(iface_names(
     116            IMedicalHistory, exclude_attribs=False,))) + (
     117            'student_id','display_fullname', 'matric_number', 'faccode',
     118            'depcode', 'state','current_session', 'current_level')
     119    title = 'Medical Questionnaire Data'
     120
     121    def mangle_value(self, value, name, context=None):
     122        """The mangler determines the titles of faculty, department
     123        and certificate. It also computes the path of passport image file
     124        stored in the filesystem.
     125        """
     126        if context is not None:
     127            student = context.student
     128            if name in ('student_id','display_fullname',
     129                'matric_number', 'faccode',
     130                'depcode', 'state','current_session',
     131                'current_level') and student is not None:
     132                value = getattr(student, name, None)
     133        return super(
     134            MedicalHistoryExporter, self).mangle_value(
     135            value, name, context=context)
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_export.py

    r16382 r16390  
    88from waeup.uniben.utils.utils import CustomKofaUtils
    99from waeup.uniben.students.export import (
    10     CustomStudentExporter, CustomStudentPaymentExporter)
     10    CustomStudentExporter, CustomStudentPaymentExporter,
     11    MedicalHistoryExporter)
    1112from waeup.uniben.testing import FunctionalLayer
    1213
     
    114115            )
    115116        return
     117
     118class MedicalHistoryExporterTest(StudentImportExportSetup):
     119
     120    layer = FunctionalLayer
     121
     122    def setUp(self):
     123        super(MedicalHistoryExporterTest, self).setUp()
     124        self.setup_for_export()
     125        return
     126
     127    def test_ifaces(self):
     128        # make sure we fullfill interface contracts
     129        obj = MedicalHistoryExporter()
     130        verifyObject(ICSVExporter, obj)
     131        verifyClass(ICSVExporter, MedicalHistoryExporter)
     132        return
     133
     134    def test_export_all(self):
     135        # we can really export students
     136        # set values we can expect in export file
     137        self.setup_student(self.student)
     138        self.student.sore_throat = True
     139        exporter = MedicalHistoryExporter()
     140        exporter.export_all(self.app, self.outfile)
     141        result = open(self.outfile, 'rb').read()
     142        self.assertMatches(
     143            'asthma,body_pains,breathing,catarrh,company_confirmed,'
     144            'company_suspected,cough,diabetes,fever,headaches,hypertension,'
     145            'lagos_abuja,medical_updated,medicines,negative,obesity,'
     146            'others,outside,positive,smell,sneezing,sore_throat,taste,'
     147            'vaccination,weakness,student_id,display_fullname,'
     148            'matric_number,faccode,depcode,state,current_session,'
     149            'current_level\r\n'
     150            ',,,,,,,,,,,,,,,,,,,,,1,,,,A111111,Anna M. Tester,234,'
     151            'NA,NA,created,2012,200\r\n' , result
     152            )
     153        return
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r16386 r16390  
    660660            'transcriptdata',
    661661            'trimmedpayments',
     662            'medicalhistory',
    662663            )
Note: See TracChangeset for help on using the changeset viewer.