Changeset 9138 for main/waeup.kofa
- Timestamp:
- 31 Aug 2012, 21:35:09 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9124 r9138 52 52 IUGStudentClearance,IPGStudentClearance, 53 53 IStudentPersonal, IStudentBase, IStudentStudyCourse, 54 IStudentStudyCourseTransfer, 54 55 IStudentAccommodation, IStudentStudyLevel, 55 56 ICourseTicket, ICourseTicketAdd, IStudentPaymentsContainer, … … 775 776 mapping = {'a':', '.join(deleted)})) 776 777 self.redirect(self.url(self.context, u'@@manage')+'?tab2') 778 return 779 780 class StudentTransferFormPage(KofaAddFormPage): 781 """Page to transfer the student. 782 """ 783 grok.context(IStudent) 784 grok.name('transfer') 785 grok.require('waeup.manageStudent') 786 label = _('Transfer student') 787 form_fields = grok.AutoFields(IStudentStudyCourseTransfer).omit( 788 'entry_mode', 'entry_session') 789 pnav = 4 790 791 def update(self): 792 super(StudentTransferFormPage, self).update() 793 warning.need() 794 return 795 796 @jsaction(_('Transfer')) 797 def transferStudent(self, **data): 798 error = self.context.transfer(**data) 799 if error == -1: 800 self.flash(_('Current level does not match certificate levels.')) 801 elif error == -2: 802 self.flash(_('Former study course record incomplete.')) 803 elif error == -3: 804 self.flash(_('Maximum number of transfers exceeded.')) 805 else: 806 self.flash(_('Successfully transferred.')) 777 807 return 778 808 -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r9131 r9138 372 372 ) 373 373 374 class IStudentStudyCourseTransfer(IStudentStudyCourse): 375 """An student transfers. 376 377 """ 378 379 certificate = schema.Choice( 380 title = _(u'Certificate'), 381 source = CertificateSource(), 382 required = True, 383 ) 384 385 current_level = schema.Choice( 386 title = _(u'Current Level'), 387 source = StudyLevelSource(), 388 required = True, 389 readonly = False, 390 ) 391 392 393 IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[ 394 'certificate'].order 395 IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[ 396 'current_level'].order 397 374 398 class IStudentVerdictUpdate(IKofaObject): 375 399 """A interface for verdict imports. -
main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
r9137 r9138 160 160 return -1 161 161 old = self['studycourse'] 162 if getattr(old, 'entry_session', None) is None or\ 163 getattr(old, 'certificate', None) is None: 164 return -2 162 165 studycourse.entry_session = old.entry_session 163 166 # Students can be transferred only two times. 164 167 if 'studycourse_1' in self.keys(): 165 168 if 'studycourse_2' in self.keys(): 166 return - 2169 return -3 167 170 self['studycourse_2'] = old 168 171 else: -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9124 r9138 1948 1948 'K1000000 - account activated' in logcontent) 1949 1949 1950 def test_student_transfer(self): 1951 # Add second certificate 1952 self.certificate2 = createObject('waeup.Certificate') 1953 self.certificate2.code = u'CERT2' 1954 self.certificate2.study_mode = 'ug_ft' 1955 self.certificate2.start_level = 999 1956 self.certificate2.end_level = 999 1957 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 1958 self.certificate2) 1959 1960 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1961 self.browser.open(self.student_path) 1962 self.browser.getLink("Transfer").click() 1963 self.browser.getControl(name="form.certificate").value = ['CERT2'] 1964 self.browser.getControl(name="form.current_session").value = ['2011'] 1965 self.browser.getControl(name="form.current_level").value = ['200'] 1966 self.browser.getControl("Transfer").click() 1967 self.assertTrue( 1968 'Current level does not match certificate levels' 1969 in self.browser.contents) 1970 self.browser.getControl(name="form.current_level").value = ['999'] 1971 self.browser.getControl("Transfer").click() 1972 self.assertTrue('Successfully transferred' in self.browser.contents) 1973 1950 1974 class StudentRequestPWTests(StudentsFullSetup): 1951 1975 # Tests for student registration -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py
r9137 r9138 308 308 error = self.student.transfer(self.certificate2, 309 309 current_session=2013) 310 self.assertTrue(error == - 2)310 self.assertTrue(error == -3) 311 311 self.assertEqual([i for i in self.student.keys()], 312 312 [u'accommodation', u'payments', u'studycourse', -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r9124 r9138 1 ## $Id$1 3## $Id$ 2 2 ## 3 3 ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann … … 166 166 target = 'manage_base' 167 167 168 class StudentTransfernButton(ManageActionButton): 169 grok.order(5) 170 grok.context(IStudent) 171 grok.view(StudentBaseDisplayFormPage) 172 grok.require('waeup.manageStudent') 173 text = _('Transfer student') 174 target = 'transfer' 175 icon = 'actionicon_redo.png' 176 168 177 class StudentDeactivateActionButton(ManageActionButton): 169 grok.order( 5)178 grok.order(6) 170 179 grok.context(IStudent) 171 180 grok.view(StudentBaseDisplayFormPage) … … 182 191 183 192 class StudentActivateActionButton(ManageActionButton): 184 grok.order( 5)193 grok.order(6) 185 194 grok.context(IStudent) 186 195 grok.view(StudentBaseDisplayFormPage) … … 285 294 target = 'manage' 286 295 296 @property 297 def target_url(self): 298 if self.context.is_current: 299 return self.view.url(self.view.context, self.target) 300 return False 301 287 302 class StudyLevelManageActionButton(ManageActionButton): 288 303 grok.order(1) … … 292 307 text = _('Manage') 293 308 target = 'manage' 309 310 @property 311 def target_url(self): 312 is_current = self.context.__parent__.is_current 313 if not is_current: 314 return '' 315 return self.view.url(self.view.context, self.target) 294 316 295 317 class StudentValidateCoursesActionButton(ManageActionButton): … … 304 326 @property 305 327 def target_url(self): 328 is_current = self.context.__parent__.is_current 306 329 if self.context.student.state != REGISTERED or \ 307 str(self.context.__parent__.current_level) != self.context.__name__: 330 str(self.context.__parent__.current_level) != self.context.__name__ or\ 331 not is_current: 308 332 return '' 309 333 return self.view.url(self.view.context, self.target) … … 320 344 @property 321 345 def target_url(self): 346 is_current = self.context.__parent__.is_current 322 347 if self.context.student.state not in (VALIDATED, REGISTERED) or \ 323 str(self.context.__parent__.current_level) != self.context.__name__: 348 str(self.context.__parent__.current_level) != self.context.__name__ or\ 349 not is_current: 324 350 return '' 325 351 return self.view.url(self.view.context, self.target) … … 334 360 target = 'course_registration.pdf' 335 361 362 @property 363 def target_url(self): 364 is_current = self.context.__parent__.is_current 365 if not is_current: 366 return '' 367 return self.view.url(self.view.context, self.target) 368 336 369 class CourseTicketManageActionButton(ManageActionButton): 337 370 grok.order(1) … … 479 512 @property 480 513 def target_url(self): 481 if self.context.next_session_allowed :514 if self.context.next_session_allowed and self.context.is_current: 482 515 return self.view.url(self.view.context, self.target) 483 516 return False … … 497 530 condition2 = str(student['studycourse'].current_level) in \ 498 531 self.view.context.keys() 499 if condition1 or condition2: 532 condition3 = not self.context.is_current 533 if condition1 or condition2 or condition3: 500 534 return '' 501 535 return self.view.url(self.view.context, self.target) … … 515 549 condition2 = student[ 516 550 'studycourse'].current_level != self.view.context.level 517 if condition1 or condition2: 551 is_current = self.context.__parent__.is_current 552 if condition1 or condition2 or not is_current: 518 553 return '' 519 554 return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.