Changeset 14984 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 5 Apr 2018, 15:30:08 (7 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportconfig.pt
r12971 r14984 50 50 </option> 51 51 </select> 52 <br /> 52 53 53 <span id="payment_dates" style="display: none;"> 54 <br /> 54 55 <label for="mode" i18n:translate=""> 55 56 Payment Date … … 65 66 <br /> 66 67 </span> 68 69 70 <span id="ct_data" style="display: none;"> 71 <br /> 72 <label for="mode" i18n:translate=""> 73 Course Ticket Level 74 </label> 75 <select name="ct_level" class="form-control half"> 76 <option tal:repeat="item view/levels" 77 tal:attributes="value python:item[1]"> 78 <span tal:replace="python: item[0]">200</span> 79 </option> 80 </select> 81 <br /> 82 <label for="mode" i18n:translate=""> 83 Course Ticket Session 84 </label> 85 <select name="ct_session" class="form-control half"> 86 <option tal:repeat="item view/sessions" 87 tal:attributes="value python:item[1]"> 88 <span tal:replace="python: item[0]">2012/2013</span> 89 </option> 90 </select> 91 <br /> 92 </span> 67 93 <br /> 94 68 95 <input type="submit" name="START" i18n:translate="" 69 96 value="Create CSV file" … … 77 104 document.getElementById('exporter').value == 'studentunpaidpayments') { 78 105 document.getElementById('payment_dates').style.display = 'block'; 106 document.getElementById('ct_data').style.display = 'none'; 107 } else if (document.getElementById('exporter').value == 'coursetickets') { 108 document.getElementById('ct_data').style.display = 'block'; 109 document.getElementById('payment_dates').style.display = 'none'; 79 110 } else { 111 document.getElementById('ct_data').style.display = 'none'; 80 112 document.getElementById('payment_dates').style.display = 'none'; 81 113 } 82 114 } 83 115 </script> 116 -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r14957 r14984 57 57 """Get course tickets of `students`. 58 58 If code is passed through, filter course tickets 59 which belong to this course code and meets level 60 and level_session. 59 which belong to this course code and meet level=level 60 and level_session=level_session. 61 If not, but ct_level and ct_session 62 are passed through, filter course tickets 63 which meet level==ct_level and level_session==ct_session. 61 64 """ 62 65 tickets = [] 63 66 code = kw.get('code', None) 64 67 level = kw.get('level', None) 65 level_session = kw.get('session', None) 68 session = kw.get('session', None) 69 ct_level = kw.get('ct_level', None) 70 ct_session = kw.get('ct_session', None) 66 71 if code is None: 67 72 for level_obj in get_levels(students): 68 73 for ticket in level_obj.values(): 74 if ct_level not in ('all', None): 75 if level_obj.level in (10, 999, None) \ 76 and int(ct_level) != level_obj.level: 77 continue 78 if level_obj.level not in range( 79 int(ct_level), int(ct_level)+100, 10): 80 continue 81 if ct_session not in ('all', None) and \ 82 int(ct_session) != level_obj.level_session: 83 continue 69 84 tickets.append(ticket) 70 85 else: … … 73 88 if ticket.code != code: 74 89 continue 75 if level is not None: 76 level = int(level) 90 if level not in ('all', None): 77 91 if level_obj.level in (10, 999, None) \ 78 92 and int(level) != level_obj.level: 79 93 continue 80 if level_obj.level not in range(level, level+100, 10): 94 if level_obj.level not in range( 95 int(level), int(level)+100, 10): 81 96 continue 82 if level_session is not Noneand \83 int( level_session) != level_obj.level_session:97 if session not in ('all', None) and \ 98 int(session) != level_obj.level_session: 84 99 continue 85 100 tickets.append(ticket) … … 101 116 if not ticket.editable_by_lecturer: 102 117 continue 103 if level is not None: 104 level = int(level) 118 if level not in ('all', None): 105 119 if level_obj.level in (10, 999, None) \ 106 120 and int(level) != level_obj.level: 107 121 continue 108 if level_obj.level not in range( level, level+100, 10):122 if level_obj.level not in range(int(level), int(level)+100, 10): 109 123 continue 110 if level_session is not Noneand \124 if level_session not in ('all', None) and \ 111 125 int(level_session) != level_obj.level_session: 112 126 continue … … 211 225 except KeyError: 212 226 pass 227 try: 228 del kw['ct_level'] 229 del kw['ct_session'] 230 except KeyError: 231 pass 213 232 query = StudentsQuery(**kw) 214 233 return query.query() -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r14642 r14984 680 680 681 681 exporter = CourseTicketExporter() 682 exporter.export_filtered( 683 self.student, self.outfile) 682 exporter.export_filtered(self.student, self.outfile) 684 683 result = open(self.outfile, 'rb').read() 685 684 self.assertEqual( … … 691 690 'Anna M. Tester\r\n' 692 691 ) 693 # if the coursetickets catalog is used to filter students 692 # We can set the course tickets level and level_session without code 693 # (used in the datacenter) 694 notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['CRS1'])) 695 exporter.export_filtered(self.student, self.outfile, ct_level='100', 696 ct_session='2012') 697 result = open(self.outfile, 'rb').read() 698 self.assertEqual( 699 result, 700 'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,' 701 'mandatory,outstanding,passmark,score,semester,title,student_id,certcode,' 702 'display_fullname\r\n' 703 '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,Course 1,A111111,CERT1,' 704 'Anna M. Tester\r\n' 705 ) 706 # 'all' does select all 707 notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['CRS1'])) 708 exporter.export_filtered(self.student, self.outfile, ct_level='all', 709 ct_session='2012') 710 result = open(self.outfile, 'rb').read() 711 self.assertEqual( 712 result, 713 'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,' 714 'mandatory,outstanding,passmark,score,semester,title,student_id,certcode,' 715 'display_fullname\r\n' 716 '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,Course 1,A111111,CERT1,' 717 'Anna M. Tester\r\n' 718 ) 719 # Level 200 tickets do not exist. 720 notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['CRS1'])) 721 exporter.export_filtered(self.student, self.outfile, ct_level='200') 722 result = open(self.outfile, 'rb').read() 723 self.assertEqual( 724 result, 725 'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,' 726 'mandatory,outstanding,passmark,score,semester,title,student_id,certcode,' 727 'display_fullname\r\n' 728 ) 729 # Session 2013 tickets do not exist. 730 notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['CRS1'])) 731 exporter.export_filtered(self.student, self.outfile, 732 ct_level='all', ct_session='2013') 733 result = open(self.outfile, 'rb').read() 734 self.assertEqual( 735 result, 736 'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,' 737 'mandatory,outstanding,passmark,score,semester,title,student_id,certcode,' 738 'display_fullname\r\n' 739 ) 740 # If the coursetickets catalog is used to filter students 694 741 # and (course) code is not None 695 742 # only course tickets which belong to this course are exported
Note: See TracChangeset for help on using the changeset viewer.