Changeset 7633
- Timestamp:
- 11 Feb 2012, 23:02:24 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/catalog.py
r7369 r7633 26 26 from waeup.sirp.interfaces import ( 27 27 IUniversity, IQueryResultItem, academic_sessions_vocab) 28 from waeup.sirp.students.interfaces import IStudent 28 from waeup.sirp.students.interfaces import (IStudent, ICourseTicket, 29 IStudentOnlinePayment) 29 30 from waeup.sirp.university.vocabularies import course_levels 30 31 … … 115 116 #: an instance of `SimpleFieldSearch` looking up students catalog. 116 117 simple_search = SimpleFieldSearch() 118 119 class CourseTicketIndexes(grok.Indexes): 120 """A catalog for course tickets. 121 """ 122 grok.site(IUniversity) 123 grok.name('coursetickets_catalog') 124 grok.context(ICourseTicket) 125 126 level = index.Field(attribute='getLevel') 127 session = index.Field(attribute='getLevelSession') 128 code = index.Field(attribute='code') 129 130 class StudentPaymentIndexes(grok.Indexes): 131 """A catalog for payments. 132 """ 133 grok.site(IUniversity) 134 grok.name('payments_catalog') 135 grok.context(IStudentOnlinePayment) 136 137 p_session = index.Field(attribute='p_session') 138 p_category = index.Field(attribute='p_category') 139 p_item = index.Field(attribute='p_item') 140 p_state = index.Field(attribute='p_state') 141 r_pay_reference = index.Text(attribute='r_pay_reference') -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r7620 r7633 377 377 ) 378 378 379 def getLevel(): 380 """Returns the id of the level the ticket has been added to. 381 """ 382 383 def getLevelSession(): 384 """Returns the session of the level the ticket has been added to. 385 """ 386 379 387 class ICourseTicketAdd(ICourseTicket): 380 388 """An interface for adding course tickets. … … 434 442 435 443 def getSessionString(): 436 """Returns the t he title of academic_sessions_vocab term.444 """Returns the title of academic_sessions_vocab term. 437 445 438 446 """ -
main/waeup.sirp/trunk/src/waeup/sirp/students/studylevel.py
r7549 r7633 100 100 return self.__parent__.__parent__.__parent__ 101 101 102 def getLevel(self): 103 """Returns the id of the level the ticket has been added to. 104 """ 105 return self.__parent__.level 106 107 def getLevelSession(self): 108 """Returns the session of the level the ticket has been added to. 109 """ 110 return self.__parent__.level_session 111 112 102 113 CourseTicket = attrs_to_fields(CourseTicket) 103 114 -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_catalog.py
r7357 r7633 26 26 from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase 27 27 from waeup.sirp.students.student import Student 28 from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket 28 29 from waeup.sirp.university.faculty import Faculty 29 30 from waeup.sirp.university.department import Department 30 31 31 32 class CatalogTestSetup(FunctionalTestCase): 32 # A setup for testing studentscatalog related stuff.33 # A setup for testing catalog related stuff. 33 34 # 34 35 # sets up a site with some student already created. … … 54 55 self.certificate) 55 56 56 # Create student with s tudycourse subobject57 # Create student with subobjects 57 58 student = Student() 58 59 student.firstname = u'Bob' … … 62 63 self.student = self.app['students'][self.student_id] 63 64 self.student['studycourse'].certificate = self.certificate 64 # Update the catalog65 # Update the students_catalog 65 66 notify(grok.ObjectModifiedEvent(self.student)) 67 studylevel = StudentStudyLevel() 68 studylevel.level = 100 69 studylevel.level_session = 2010 70 self.student['studycourse']['100'] = studylevel 71 ticket = CourseTicket() 72 ticket.code = 'Course1' 73 self.student['studycourse']['100']['Course1'] = ticket 74 payment = createObject(u'waeup.StudentOnlinePayment') 75 payment.p_id = 'p1234567890' 76 payment.p_item = u'any item' 77 payment.p_session = 2010 78 payment.p_category = 'schoolfee' 79 payment.p_state = 'paid' 80 payment.r_pay_reference = u'GTB|WEB|FUT' 81 self.student['payments'][payment.p_id] = payment 66 82 return 67 83 … … 111 127 assert len(results) == 1 112 128 assert results[0] is self.app['students'][self.student_id] 129 130 class CourseTicketCatalogTests(CatalogTestSetup): 131 132 layer = FunctionalLayer 133 134 def test_get_catalog(self): 135 # We can get an students catalog if we wish 136 cat = queryUtility(ICatalog, name='coursetickets_catalog') 137 assert cat is not None 138 139 def test_search_by_code(self): 140 # We can find a certain course ticket by its code 141 cat = queryUtility(ICatalog, name='coursetickets_catalog') 142 results = cat.searchResults(code=('Course1', 'Course1')) 143 results = [x for x in results] # Turn results generator into list 144 assert len(results) == 1 145 assert results[0] is self.app['students'][self.student_id][ 146 'studycourse']['100']['Course1'] 147 148 def test_search_by_level(self): 149 # We can find a certain course ticket by the level 150 cat = queryUtility(ICatalog, name='coursetickets_catalog') 151 results = cat.searchResults(level=(100, 100)) 152 results = [x for x in results] # Turn results generator into list 153 assert len(results) == 1 154 assert results[0] is self.app['students'][self.student_id][ 155 'studycourse']['100']['Course1'] 156 157 def test_search_by_session(self): 158 # We can find a certain course ticket by the level session 159 cat = queryUtility(ICatalog, name='coursetickets_catalog') 160 results = cat.searchResults(session=(2010, 2010)) 161 results = [x for x in results] # Turn results generator into list 162 assert len(results) == 1 163 assert results[0] is self.app['students'][self.student_id][ 164 'studycourse']['100']['Course1'] 165 166 class PaymentCatalogTests(CatalogTestSetup): 167 168 layer = FunctionalLayer 169 170 def test_get_catalog(self): 171 # We can get an students catalog if we wish 172 cat = queryUtility(ICatalog, name='payments_catalog') 173 assert cat is not None 174 175 def test_search_by_session(self): 176 # We can find a payment ticket by the payment session 177 cat = queryUtility(ICatalog, name='payments_catalog') 178 results = cat.searchResults(p_session=(2010, 2010)) 179 results = [x for x in results] # Turn results generator into list 180 assert len(results) == 1 181 assert results[0] is self.app['students'][self.student_id][ 182 'payments']['p1234567890'] 183 184 def test_search_by_category(self): 185 # We can find a payment ticket by the payment category 186 cat = queryUtility(ICatalog, name='payments_catalog') 187 results = cat.searchResults(p_category=('schoolfee','schoolfee')) 188 results = [x for x in results] # Turn results generator into list 189 assert len(results) == 1 190 assert results[0] is self.app['students'][self.student_id][ 191 'payments']['p1234567890'] 192 193 def test_search_by_item(self): 194 # We can find a payment ticket by the payment item 195 cat = queryUtility(ICatalog, name='payments_catalog') 196 results = cat.searchResults(p_item=('any item','any item')) 197 results = [x for x in results] # Turn results generator into list 198 assert len(results) == 1 199 assert results[0] is self.app['students'][self.student_id][ 200 'payments']['p1234567890'] 201 202 def test_search_by_state(self): 203 # We can find a payment ticket by the payment state 204 cat = queryUtility(ICatalog, name='payments_catalog') 205 results = cat.searchResults(p_state=('paid','paid')) 206 results = [x for x in results] # Turn results generator into list 207 assert len(results) == 1 208 assert results[0] is self.app['students'][self.student_id][ 209 'payments']['p1234567890'] 210 211 def test_search_by_reference(self): 212 # We can find a payment ticket by parts of the response reference 213 cat = queryUtility(ICatalog, name='payments_catalog') 214 results = cat.searchResults(r_pay_reference='GTB') 215 results = [x for x in results] # Turn results generator into list 216 assert len(results) == 1 217 assert results[0] is self.app['students'][self.student_id][ 218 'payments']['p1234567890']
Note: See TracChangeset for help on using the changeset viewer.