Changeset 16390 for main/waeup.uniben/trunk/src
- Timestamp:
- 29 Jan 2021, 11:03:57 (4 years ago)
- 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 18 18 """Exporters for student related stuff. 19 19 """ 20 import grok 20 21 from datetime import datetime 21 22 from waeup.uniben.students.interfaces import ( … … 24 25 ICustomStudentStudyLevel, 25 26 ICustomCourseTicket, 26 ICustomStudentOnlinePayment) 27 ICustomStudentOnlinePayment, 28 IMedicalHistory) 27 29 from kofacustom.nigeria.students.export import ( 28 30 NigeriaStudentExporter, … … 33 35 NigeriaDataForBursaryExporter, 34 36 ) 35 from waeup.kofa.students.export import SchoolFeePaymentsOverviewExporter 37 from waeup.kofa.students.export import ( 38 SchoolFeePaymentsOverviewExporter, StudentExporterBase) 36 39 from waeup.kofa.utils.helpers import iface_names 37 40 … … 103 106 'entry_session', 'reg_number' 104 107 ) + year_range_tuple 108 109 class 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 8 8 from waeup.uniben.utils.utils import CustomKofaUtils 9 9 from waeup.uniben.students.export import ( 10 CustomStudentExporter, CustomStudentPaymentExporter) 10 CustomStudentExporter, CustomStudentPaymentExporter, 11 MedicalHistoryExporter) 11 12 from waeup.uniben.testing import FunctionalLayer 12 13 … … 114 115 ) 115 116 return 117 118 class 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 660 660 'transcriptdata', 661 661 'trimmedpayments', 662 'medicalhistory', 662 663 )
Note: See TracChangeset for help on using the changeset viewer.