Changeset 12518 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 27 Jan 2015, 14:48:22 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/datacenterexportpage.pt
r11826 r12518 38 38 39 39 <p i18n:translate=""> 40 Student data exports have to be further configured. You can create CSV files 41 on the <a href="@@exportconfig">student data export configuration page</a>. 40 Student data exports have to be further configured. You can either refine 41 the results by <a href="@@exportconfig">selecting certain export paramers</a> 42 or by <a href="@@exportselected">entering a set of student ids</a>. 42 43 </p> 43 44 -
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r11730 r12518 318 318 self.assertEqual(self.browser.url, self.datacenter_path) 319 319 self.browser.getLink("Export data").click() 320 self.browser.getLink(" configuration page").click()320 self.browser.getLink("selecting certain export paramers").click() 321 321 self.browser.getControl(name="exporter").value = ['students'] 322 322 self.browser.getControl(name="session").value = ['all'] -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r12474 r12518 3282 3282 redirect_target = '@@export' 3283 3283 3284 class DatacenterExportJobContainerSelectStudents(ExportJobContainerJobConfig): 3285 """Page that configures a students export job in datacenter. 3286 3287 """ 3288 grok.name('exportselected') 3289 grok.context(IDataCenter) 3290 redirect_target = '@@export' 3291 grok.template('exportselected') 3292 label = _('Configure student data export') 3293 3294 def update(self, START=None, students=None, exporter=None): 3295 self._set_exporter_values() 3296 if START is None: 3297 return 3298 try: 3299 ids = students.replace(',', ' ').split() 3300 except: 3301 self.flash(sys.exc_info()[1]) 3302 self.redirect(self.url(self.redirect_target)) 3303 return 3304 job_id = self.context.start_export_job( 3305 exporter, self.request.principal.id, selected=ids) 3306 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 3307 self.context.logger.info( 3308 '%s - selected students exported: %s, job_id=%s' % 3309 (ob_class, exporter, job_id)) 3310 self.flash(_('Export of selected students started.')) 3311 self.redirect(self.url(self.redirect_target)) 3312 return 3313 3284 3314 class FacultiesExportJobContainerJobConfig(ExportJobContainerJobConfig): 3285 3315 """Page that configures a students export job in facultiescontainer. -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r12104 r12518 190 190 return query.query() 191 191 192 def get_selected(self, site, selected): 193 """Get set of selected students. 194 195 Returns a simple empty list or a list with `Student` 196 objects. 197 """ 198 students = [] 199 students_container = site.get('students', {}) 200 for id in selected: 201 student = students_container.get(id, None) 202 if student: 203 students.append(student) 204 return students 205 192 206 def export(self, values, filepath=None): 193 207 """Export `values`, an iterable, as CSV file. … … 217 231 """ 218 232 data = self.get_filtered(site, **kw) 233 return self.export(self.filter_func(data, **kw), filepath=filepath) 234 235 def export_selected(self,site, filepath=None, **kw): 236 """Export data for selected set of students. 237 """ 238 selected = kw.get('selected', []) 239 data = self.get_selected(site, selected) 219 240 return self.export(self.filter_func(data, **kw), filepath=filepath) 220 241 -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r11589 r12518 872 872 """ 873 873 874 def get_selected(site, selected): 875 """Get set of selected students. 876 """ 877 874 878 def export_student(student, filepath=None): 875 879 """Export data for a given student. … … 877 881 878 882 def export_filtered(site, filepath=None, **kw): 879 """Export filtered set of students. 880 """ 883 """Export data for filtered set of students. 884 """ 885 886 def export_selected(site, filepath=None, **kw): 887 """Export data for selected set of students. 888 """ -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r12393 r12518 3313 3313 ) 3314 3314 3315 def test_datacenter_export_selected(self): 3316 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 3317 self.browser.open('http://localhost/app/datacenter/@@exportselected') 3318 self.browser.getControl(name="exporter").value = ['students'] 3319 self.browser.getControl(name="students").value = 'K1000000' 3320 self.browser.getControl("Create CSV file").click() 3321 # When the job is finished and we reload the page... 3322 job_id = self.wait_for_export_job_completed() 3323 # ... the csv file can be downloaded ... 3324 self.browser.open('http://localhost/app/datacenter/@@export') 3325 self.browser.getLink("Download").click() 3326 self.assertEqual(self.browser.headers['content-type'], 3327 'text/csv; charset=UTF-8') 3328 self.assertTrue( 3329 'filename="WAeUP.Kofa_students_%s.csv' % job_id in 3330 self.browser.headers['content-disposition']) 3331 self.assertTrue( 3332 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 3333 'firstname,lastname,matric_number,middlename,nationality,' 3334 'officer_comment,perm_address,personal_updated,phone,reg_number,' 3335 'sex,student_id,suspended,suspended_comment,transcript_comment,' 3336 'password,state,history,certcode,is_postgrad,current_level,' 3337 'current_session\r\n' 3338 ',1,,1981-02-04#,aa@aa.ng,,Anna,Tester,234,,,,,,' 3339 '1234#,123,m,K1000000,0,,,{SSHA}' in self.browser.contents) 3340 3315 3341 def test_payment_dates(self): 3316 3342 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r12393 r12518 262 262 return 263 263 264 def test_export_selected(self): 265 # we can export a filtered set of students (filtered by session/level) 266 self.setup_student(self.student) 267 self.app['students'].addStudent(self.student) 268 notify(grok.ObjectModifiedEvent(self.student)) 269 exporter = StudentExporter() 270 exporter.export_selected( 271 self.app, self.outfile, selected=['A111111']) 272 result1 = open(self.outfile, 'rb').read() 273 exporter.export_selected( 274 self.app, self.outfile, selected=[]) 275 result2 = open(self.outfile, 'rb').read() 276 self.assertTrue(self.std_csv_entry in result1) 277 self.assertFalse(self.std_csv_entry in result2) 278 return 279 264 280 def test_export_filtered_by_dept(self): 265 281 # we can export a set of students filtered by department … … 405 421 return 406 422 423 def test_export_selected(self): 424 # we can export a filtered set of students (filtered by session/level) 425 self.setup_student(self.student) 426 self.app['students'].addStudent(self.student) 427 notify(grok.ObjectModifiedEvent(self.student)) 428 exporter = StudentStudyCourseExporter() 429 exporter.export_selected( 430 self.app, self.outfile, selected=['A111111']) 431 result = open(self.outfile, 'rb').read() 432 self.assertEqual( 433 result, 434 'certificate,current_level,current_session,current_verdict,' 435 'entry_mode,entry_session,previous_verdict,student_id\r\n' 436 437 'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n' 438 ) 439 return 407 440 408 441 … … 502 535 exporter.export_filtered( 503 536 self.student, self.outfile) 537 result = open(self.outfile, 'rb').read() 538 self.assertEqual( 539 result, 540 'gpa,level,level_session,level_verdict,total_credits,' 541 'validated_by,validation_date,' 542 'student_id,number_of_tickets,certcode\r\n' 543 '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n' 544 ) 545 return 546 547 def test_export_selected(self): 548 # we can export studylevels of a filtered set of students 549 self.setup_student(self.student) 550 self.app['students'].addStudent(self.student) 551 notify(grok.ObjectModifiedEvent(self.student)) 552 553 exporter = StudentStudyLevelExporter() 554 exporter.export_selected( 555 self.app, self.outfile, selected=['A111111']) 504 556 result = open(self.outfile, 'rb').read() 505 557 self.assertEqual(
Note: See TracChangeset for help on using the changeset viewer.