Changeset 9844 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 8 Jan 2013, 13:33:14 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9843 r9844 2810 2810 2811 2811 def _set_exporter_values(self): 2812 # We provide only t he students exporter.2812 # We provide only two exporters. 2813 2813 exporters = [] 2814 for name in ('students', ):2814 for name in ('students', 'coursetickets'): 2815 2815 util = getUtility(ICSVExporter, name=name) 2816 2816 exporters.append((util.title, name),) -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r9843 r9844 56 56 return levels 57 57 58 def get_tickets(students): 59 """Get all course tickets of `students`. 58 def get_tickets(students, **kw): 59 """Get course tickets of `students`. 60 61 If code is passed through filter course tickets 62 which belong to this course code. 60 63 """ 61 64 tickets = [] 62 for level in get_levels(students): 63 for ticket in level.values(): 64 tickets.append(ticket) 65 code = kw.get('code', None) 66 if code is None: 67 for level in get_levels(students): 68 for ticket in level.values(): 69 tickets.append(ticket) 70 else: 71 for level in get_levels(students): 72 for ticket in level.values(): 73 if ticket.code == code: 74 tickets.append(ticket) 65 75 return tickets 66 76 … … 92 102 grok.provides(ICSVStudentExporter) 93 103 94 def filter_func(self, x ):104 def filter_func(self, x, **kw): 95 105 return x 96 106 … … 149 159 """ 150 160 data = self.get_filtered(site, **kw) 151 return self.export(self.filter_func(data ), filepath=filepath)161 return self.export(self.filter_func(data, **kw), filepath=filepath) 152 162 153 163 … … 189 199 title = _(u'Student Study Courses') 190 200 191 def filter_func(self, x ):201 def filter_func(self, x, **kw): 192 202 return get_studycourses(x) 193 203 … … 219 229 title = _(u'Student Study Levels') 220 230 221 def filter_func(self, x ):231 def filter_func(self, x, **kw): 222 232 return get_levels(x) 223 233 … … 244 254 title = _(u'Course Tickets') 245 255 246 def filter_func(self, x ):247 return get_tickets(x )256 def filter_func(self, x, **kw): 257 return get_tickets(x, **kw) 248 258 249 259 def mangle_value(self, value, name, context=None): … … 275 285 title = _(u'Student Payments') 276 286 277 def filter_func(self, x ):287 def filter_func(self, x, **kw): 278 288 return get_payments(x) 279 289 … … 303 313 title = _(u'Bed Tickets') 304 314 305 def filter_func(self, x ):315 def filter_func(self, x, **kw): 306 316 return get_bedtickets(x) 307 317 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9843 r9844 2835 2835 ) 2836 2836 2837 def test_course_export (self):2837 def test_course_export_students(self): 2838 2838 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 2839 2839 course1_path = 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1' … … 2880 2880 '- discarded: job_id=%s' % job_id in logcontent 2881 2881 ) 2882 2883 def test_course_export_coursetickets(self): 2884 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 2885 course1_path = 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1' 2886 self.browser.open(course1_path) 2887 self.browser.getLink("Export student data").click() 2888 self.browser.getControl("Configure new export").click() 2889 self.browser.getControl(name="exporter").value = ['coursetickets'] 2890 self.browser.getControl(name="session").value = ['2004'] 2891 self.browser.getControl(name="level").value = ['100'] 2892 self.browser.getControl("Create CSV file").click() 2893 2894 # When the job is finished and we reload the page... 2895 job_id = self.wait_for_export_job_completed() 2896 self.browser.open(course1_path + '/exports') 2897 # ... the csv file can be downloaded ... 2898 self.browser.getLink("Download").click() 2899 self.assertEqual(self.browser.headers['content-type'], 2900 'text/csv; charset=UTF-8') 2901 self.assertTrue( 2902 'filename="WAeUP.Kofa_coursetickets_%s.csv' % job_id in 2903 self.browser.headers['content-disposition']) 2904 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 2905 job_id = self.app['datacenter'].running_exports[0][0] 2906 # ... and discarded 2907 self.browser.open(course1_path + '/exports') 2908 self.browser.getControl("Discard").click() 2909 self.assertEqual(len(self.app['datacenter'].running_exports), 0) 2910 # Creation, downloading and discarding is logged 2911 logfile = os.path.join( 2912 self.app['datacenter'].storage, 'logs', 'datacenter.log') 2913 logcontent = open(logfile).read() 2914 self.assertTrue( 2915 'zope.mgr - students.browser.CourseExportJobContainerJobConfig ' 2916 '- exported: coursetickets (2004, 100, COURSE1), job_id=%s' 2917 % job_id in logcontent 2918 ) 2919 self.assertTrue( 2920 'zope.mgr - students.browser.ExportJobContainerDownload ' 2921 '- downloaded: WAeUP.Kofa_coursetickets_%s.csv, job_id=%s' 2922 % (job_id, job_id) in logcontent 2923 ) 2924 self.assertTrue( 2925 'zope.mgr - students.browser.ExportJobContainerOverview ' 2926 '- discarded: job_id=%s' % job_id in logcontent 2927 ) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9832 r9844 554 554 555 555 def test_export_filtered(self): 556 # we can export studylevels of a filtered set of students556 # we can export course tickets of a filtered set of students 557 557 self.setup_student(self.student) 558 558 self.app['students'].addStudent(self.student) … … 568 568 'passmark,score,semester,title,student_id,certcode\r\n' 569 569 '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n' 570 ) 571 # if the coursetickets catalog is used to filter students 572 # and (course) code is not None 573 # only course tickets which belong to this course are exported 574 exporter.export_filtered( 575 self.student, self.outfile, cat='coursetickets', code='CRS1') 576 result = open(self.outfile, 'rb').read() 577 self.assertEqual( 578 result, 579 'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,' 580 'passmark,score,semester,title,student_id,certcode\r\n' 581 '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n' 582 ) 583 exporter.export_filtered( 584 self.student, self.outfile, cat='coursetickets', code='any code') 585 result = open(self.outfile, 'rb').read() 586 self.assertEqual( 587 result, 588 'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,' 589 'passmark,score,semester,title,student_id,certcode\r\n' 570 590 ) 571 591 return
Note: See TracChangeset for help on using the changeset viewer.