Changeset 10041 for main/waeup.kofa/trunk
- Timestamp:
- 21 Mar 2013, 10:57:48 (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
r10040 r10041 109 109 self.assertEqual(result, 110 110 {'100|CRS1': 'Course 1', '100|COURSE1': 'Unnamed Course'}) 111 # Also matric_number ... 112 result = server.get_courses_by_session('234') 113 self.assertEqual(result, 114 {'100|CRS1': 'Course 1', '100|COURSE1': 'Unnamed Course'}) 115 # ... or reg_number can be used. 116 result = server.get_courses_by_session('123') 117 self.assertEqual(result, 118 {'100|CRS1': 'Course 1', '100|COURSE1': 'Unnamed Course'}) 119 result = server.get_courses_by_session('Nonsense') 120 self.assertEqual(result, None) 111 121 REQUEST_XML="""\ 112 122 <?xml version="1.0"?> -
main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py
r10040 r10041 22 22 from waeup.kofa.interfaces import IUniversity 23 23 24 def get_student(students, identifier): 25 if identifier is None: 26 return None 27 student = students.get(identifier, None) 28 if student is None: 29 cat = queryUtility(ICatalog, name='students_catalog') 30 results = list( 31 cat.searchResults(matric_number=(identifier, identifier))) 32 if len(results) == 1: 33 student = results[0] 34 else: 35 results = list( 36 cat.searchResults(reg_number=(identifier, identifier))) 37 if len(results) == 1: 38 student = results[0] 39 return student 24 40 25 41 #class XMLRPCPermission(grok.Permission): … … 61 77 62 78 @grok.require('waeup.xmlrpc') 63 def get_courses_by_session(self, student_id=None, session=None):79 def get_courses_by_session(self, identifier=None, session=None): 64 80 """What COURSES are registered by student X in session Y? 65 81 66 82 """ 67 if student_id is None: 83 students = self.context['students'] 84 student = get_student(students, identifier) 85 if student is None: 68 86 return None 69 student = self.context['students'].get(student_id, None)70 if student is None:71 return None72 87 try: 73 88 session = int(session)
Note: See TracChangeset for help on using the changeset viewer.