Changeset 12632 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 26 Feb 2015, 07:35:00 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r12518 r12632 53 53 from waeup.kofa.university.interfaces import ( 54 54 IDepartment, ICertificate, ICourse) 55 from waeup.kofa.university. department import (56 VirtualDepartmentExportJobContainer,) 55 from waeup.kofa.university.faculty import VirtualFacultyExportJobContainer 56 from waeup.kofa.university.department import VirtualDepartmentExportJobContainer 57 57 from waeup.kofa.university.facultiescontainer import ( 58 58 VirtualFacultiesExportJobContainer, FacultiesContainer) … … 3192 3192 3193 3193 @property 3194 def faccode(self): 3195 return None 3196 3197 @property 3194 3198 def depcode(self): 3195 3199 return None … … 3227 3231 if payments_end == '': 3228 3232 payments_end = None 3229 if (mode, level, session, 3230 self.depcode, self.certcode) == (None, None, None, None, None): 3233 if (mode, 3234 level, 3235 session, 3236 self.faccode, 3237 self.depcode, 3238 self.certcode) == (None, None, None, None, None, None): 3231 3239 # Export all students including those without certificate 3232 3240 if payments_start: … … 3245 3253 current_level=level, 3246 3254 current_mode=mode, 3255 faccode=self.faccode, 3247 3256 depcode=self.depcode, 3248 3257 certcode=self.certcode, … … 3255 3264 current_level=level, 3256 3265 current_mode=mode, 3266 faccode=self.faccode, 3257 3267 depcode=self.depcode, 3258 3268 certcode=self.certcode) 3259 3269 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 3260 3270 self.context.logger.info( 3261 '%s - exported: %s (%s, %s, %s, %s, %s, %s, %s ), job_id=%s'3262 % (ob_class, exporter, session, level, mode, self. depcode,3263 self. certcode, payments_start, payments_end, job_id))3271 '%s - exported: %s (%s, %s, %s, %s, %s, %s, %s, %s), job_id=%s' 3272 % (ob_class, exporter, session, level, mode, self.faccode, 3273 self.depcode, self.certcode, payments_start, payments_end, job_id)) 3264 3274 self.flash(_('Export started for students with') + 3265 3275 ' current_session=%s, current_level=%s, study_mode=%s' % ( … … 3317 3327 """ 3318 3328 grok.context(VirtualFacultiesExportJobContainer) 3329 3330 3331 class FacultyExportJobContainerJobConfig(ExportJobContainerJobConfig): 3332 """Page that configures a students export job in faculties. 3333 3334 """ 3335 grok.context(VirtualFacultyExportJobContainer) 3336 3337 @property 3338 def faccode(self): 3339 return self.context.__parent__.code 3319 3340 3320 3341 class DepartmentExportJobContainerJobConfig(ExportJobContainerJobConfig): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r12518 r12632 3299 3299 self.assertTrue( 3300 3300 'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig ' 3301 '- exported: bursary (2004, 100, ug_ft, None, None, '3301 '- exported: bursary (2004, 100, ug_ft, None, None, None, ' 3302 3302 '13/12/2012, 14/12/2012), job_id=%s' 3303 3303 % job_id in logcontent … … 3389 3389 self.assertTrue( 3390 3390 'zope.mgr - students.browser.FacultiesExportJobContainerJobConfig ' 3391 '- exported: bursary (2004, 100, ug_ft, None, None, '3391 '- exported: bursary (2004, 100, ug_ft, None, None, None, ' 3392 3392 '13/12/2012, 14/12/2012), job_id=%s' 3393 3393 % job_id in logcontent … … 3396 3396 'zope.mgr - students.browser.ExportJobContainerDownload ' 3397 3397 '- downloaded: WAeUP.Kofa_bursary_%s.csv, job_id=%s' 3398 % (job_id, job_id) in logcontent 3399 ) 3400 self.assertTrue( 3401 'zope.mgr - students.browser.ExportJobContainerOverview ' 3402 '- discarded: job_id=%s' % job_id in logcontent 3403 ) 3404 3405 def test_faculty_export(self): 3406 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 3407 fac1_path = 'http://localhost/app/faculties/fac1' 3408 self.browser.open(fac1_path) 3409 self.browser.getLink("Export student data").click() 3410 self.browser.getControl("Configure new export").click() 3411 self.browser.getControl(name="exporter").value = ['students'] 3412 self.browser.getControl(name="session").value = ['2004'] 3413 self.browser.getControl(name="level").value = ['100'] 3414 self.browser.getControl(name="mode").value = ['ug_ft'] 3415 # The testbrowser does not hide the payment period fields, but 3416 # values are ignored when using the students exporter. 3417 self.browser.getControl(name="payments_start").value = '13/12/2012' 3418 self.browser.getControl(name="payments_end").value = '14/12/2012' 3419 self.browser.getControl("Create CSV file").click() 3420 3421 # When the job is finished and we reload the page... 3422 job_id = self.wait_for_export_job_completed() 3423 self.browser.open(fac1_path + '/exports') 3424 # ... the csv file can be downloaded ... 3425 self.browser.getLink("Download").click() 3426 self.assertEqual(self.browser.headers['content-type'], 3427 'text/csv; charset=UTF-8') 3428 self.assertTrue( 3429 'filename="WAeUP.Kofa_students_%s.csv' % job_id in 3430 self.browser.headers['content-disposition']) 3431 self.assertTrue( 3432 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 3433 'firstname,lastname,matric_number,middlename,nationality,' 3434 'officer_comment,perm_address,personal_updated,phone,reg_number,' 3435 'sex,student_id,suspended,suspended_comment,transcript_comment,' 3436 'password,state,history,certcode,is_postgrad,current_level,' 3437 'current_session\r\n' 3438 ',1,,1981-02-04#,aa@aa.ng,,Anna,Tester,234,,,,,,' 3439 '1234#,123,m,K1000000,0,,,{SSHA}' in self.browser.contents) 3440 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 3441 job_id = self.app['datacenter'].running_exports[0][0] 3442 # ... and discarded 3443 self.browser.open(fac1_path + '/exports') 3444 self.browser.getControl("Discard").click() 3445 self.assertEqual(len(self.app['datacenter'].running_exports), 0) 3446 # Creation, downloading and discarding is logged 3447 logfile = os.path.join( 3448 self.app['datacenter'].storage, 'logs', 'datacenter.log') 3449 logcontent = open(logfile).read() 3450 self.assertTrue( 3451 'zope.mgr - students.browser.FacultyExportJobContainerJobConfig ' 3452 '- exported: students (2004, 100, ug_ft, fac1, None, None, ' 3453 '13/12/2012, 14/12/2012), job_id=%s' 3454 % job_id in logcontent 3455 ) 3456 self.assertTrue( 3457 'zope.mgr - students.browser.ExportJobContainerDownload ' 3458 '- downloaded: WAeUP.Kofa_students_%s.csv, job_id=%s' 3398 3459 % (job_id, job_id) in logcontent 3399 3460 ) … … 3441 3502 self.assertTrue( 3442 3503 'zope.mgr - students.browser.DepartmentExportJobContainerJobConfig ' 3443 '- exported: students (2004, 100, ug_ft, dep1, None, '3504 '- exported: students (2004, 100, ug_ft, None, dep1, None, ' 3444 3505 '13/12/2012, 14/12/2012), job_id=%s' 3445 3506 % job_id in logcontent … … 3488 3549 self.assertTrue( 3489 3550 'zope.mgr - students.browser.CertificateExportJobContainerJobConfig ' 3490 '- exported: students (2004, 100, None, None, CERT1, None, None), '3551 '- exported: students (2004, 100, None, None, None, CERT1, None, None), ' 3491 3552 'job_id=%s' 3492 3553 % job_id in logcontent
Note: See TracChangeset for help on using the changeset viewer.