Changeset 16195
- Timestamp:
- 11 Aug 2020, 12:34:08 (4 years ago)
- Location:
- main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/export.py
r15351 r16195 32 32 CourseTicketExporter, 33 33 StudentPaymentExporter, 34 DataForBursaryExporter) 34 DataForBursaryExporter, 35 TrimmedDataExporter) 35 36 from waeup.kofa.utils.helpers import iface_names 36 37 from kofacustom.nigeria.interfaces import MessageFactory as _ … … 50 51 return super( 51 52 NigeriaStudentExporter, self).mangle_value( 53 value, name, context=context) 54 55 class NigeriaTrimmedDataExporter(TrimmedDataExporter): 56 """The Student Trimmed Data Exporter first filters the set of students 57 by searching the students catalog. Then it exports a trimmed data set 58 of this set of students. 59 """ 60 61 fields = ( 62 'student_id', 63 'matric_number', 64 'reg_number', 65 'firstname', 66 'middlename', 67 'lastname', 68 'sex', 69 'email', 70 'phone', 71 'nationality', 72 'date_of_birth', 73 'state', 74 'current_mode', 75 'certcode', 76 'faccode', 77 'depcode', 78 'current_level', 79 'current_session', 80 'current_verdict', 81 'entry_session', 82 'lg_state', 83 'lg_area') 84 85 def mangle_value(self, value, name, context=None): 86 if name == 'lg_state': 87 value = context.lga.split('_')[0] 88 if name == 'lg_area': 89 value = '-'.join(context.lga.split('_')[1:]) 90 return super( 91 NigeriaTrimmedDataExporter, self).mangle_value( 52 92 value, name, context=context) 53 93 -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_export.py
r15731 r16195 26 26 from kofacustom.nigeria.students.export import ( 27 27 NigeriaStudentExporter, NigeriaStudentPaymentExporter, 28 ClearanceRequestedStudentExporter, NigeriaDataForBursaryExporter) 28 ClearanceRequestedStudentExporter, NigeriaDataForBursaryExporter, 29 NigeriaTrimmedDataExporter) 29 30 from kofacustom.nigeria.testing import FunctionalLayer 30 31 … … 200 201 ) 201 202 return 203 204 class NigeriaStudentTrimmedDataExporterTest(StudentImportExportSetup): 205 206 layer = FunctionalLayer 207 208 std_csv_entry = ( 209 'my adm code,my clr code,1981-02-04#,anna@sample.com,,' 210 'Anna,,Tester,234,M.,NG,,,"Studentroad 21\nLagos 123456\n",,' 211 '+234-123-12345#,123,f,A111111,0,,,created' 212 ) 213 214 def setUp(self): 215 super(NigeriaStudentTrimmedDataExporterTest, self).setUp() 216 self.setup_for_export() 217 self.student.lga = 'abia_aba_north' 218 return 219 220 def test_export_all(self): 221 # we can really export students 222 # set values we can expect in export file 223 self.setup_student(self.student) 224 exporter = NigeriaTrimmedDataExporter() 225 exporter.export_all(self.app, self.outfile) 226 result = open(self.outfile, 'rb').read() 227 self.assertTrue( 228 'student_id,matric_number,reg_number,firstname,middlename,' 229 'lastname,sex,email,phone,nationality,date_of_birth,state,' 230 'current_mode,certcode,faccode,depcode,current_level,' 231 'current_session,current_verdict,entry_session,lg_state,lg_area\r\n' 232 'A111111,234,123,Anna,M.,Tester,f,anna@sample.com,+234-123-12345#,' 233 'NG,1981-02-04#,created,ug_ft,CERT1,NA,NA,200,2012,0,2010,' 234 'abia,aba-north' 235 in result 236 ) 237 return
Note: See TracChangeset for help on using the changeset viewer.