Changeset 10038 for main/waeup.kofa/trunk
- Timestamp:
- 18 Mar 2013, 10:56:41 (12 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/tests/test_webservices.py
r10037 r10038 20 20 study_level.level_verdict = "A" 21 21 study_level.level = 100 22 study_level.validated_by = u"my adviser" 22 23 student['studycourse'].addStudentStudyLevel( 23 24 self.certificate, study_level) … … 146 147 self.assertEqual(self.browser.contents, RESPONSE_XML) 147 148 return 149 150 def test_get_students_by_course(self): 151 self.setup_student(self.student) 152 server = ServerProxy('http://mgr:mgrpw@localhost/app') 153 result = server.get_students_by_course('CRS1', '2010') 154 self.assertEqual(result, None) 155 result = server.get_students_by_course('CRS1', '2012') 156 self.assertEqual(result, ['K1000000|234|my adviser']) 157 result = server.get_students_by_course('CRS1') 158 self.assertEqual(result, ['K1000000|234|my adviser']) 159 return -
main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py
r10036 r10038 18 18 19 19 import grok 20 from zope.component import getUtility 20 from zope.component import getUtility, queryUtility 21 21 from zope.catalog.interfaces import ICatalog 22 22 from waeup.kofa.interfaces import IUniversity … … 62 62 @grok.require('waeup.xmlrpc') 63 63 def get_courses_by_session(self, student_id=None, session=None): 64 """ Get the course tickets registered by a student in a certain session.64 """What COURSES are registered by student X in session Y? 65 65 66 66 """ … … 88 88 return None 89 89 return coursetickets 90 91 @grok.require('waeup.xmlrpc') 92 def get_students_by_course(self, course=None, session=None): 93 """What STUDENTS registered (student id / matric no) 94 for course Z in session Y? 95 96 (a) Authorized by course adviser. 97 (b) Not authorized by course adviser. 98 """ 99 try: 100 session = int(session) 101 except (TypeError, ValueError): 102 pass 103 sessionsearch = True 104 if session in (None, ''): 105 sessionsearch = False 106 cat = queryUtility(ICatalog, name='coursetickets_catalog') 107 if sessionsearch: 108 coursetickets = cat.searchResults( 109 session=(session, session), 110 code=(course, course)) 111 else: 112 coursetickets = cat.searchResults( 113 code=(course, course)) 114 if not coursetickets: 115 return None 116 hitlist = [] 117 for ticket in coursetickets: 118 hitlist.append('%s|%s|%s' % ( 119 ticket.student.student_id, 120 ticket.student.matric_number, 121 ticket.__parent__.validated_by)) 122 return list(set(hitlist))
Note: See TracChangeset for help on using the changeset viewer.