Changeset 14591 for main/waeup.fceokene/trunk/src
- Timestamp:
- 25 Feb 2017, 17:59:16 (8 years ago)
- Location:
- main/waeup.fceokene/trunk/src/waeup/fceokene/students
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.fceokene/trunk/src/waeup/fceokene/students/browser.py
r13060 r14591 24 24 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget 25 25 from waeup.kofa.students.browser import ( 26 StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlip) 26 StartClearancePage, BedTicketAddPage, 27 ExportPDFAdmissionSlip, StudyLevelDisplayFormPage) 27 28 from kofacustom.nigeria.students.browser import ( 28 29 NigeriaOnlinePaymentDisplayFormPage, … … 30 31 NigeriaExportPDFPaymentSlip, 31 32 NigeriaStudentClearanceEditFormPage, 32 NigeriaExportPDFClearanceSlip 33 NigeriaExportPDFClearanceSlip, 34 NigeriaExportPDFCourseRegistrationSlip 33 35 ) 34 36 35 37 from waeup.fceokene.students.interfaces import ( 36 ICustomStudentOnlinePayment, ICustomUGStudentClearance) 38 ICustomStudentOnlinePayment, ICustomUGStudentClearance, 39 ICustomStudentStudyLevel) 37 40 38 41 class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): … … 141 144 notice = '' 142 145 with_ac = False 146 147 class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): 148 """ Page to display student study levels 149 """ 150 grok.context(ICustomStudentStudyLevel) 151 form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') 152 form_fields[ 153 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 154 155 class CustomExportPDFCourseRegistrationSlip( 156 NigeriaExportPDFCourseRegistrationSlip): 157 """Deliver a PDF slip of the context. 158 """ 159 grok.context(ICustomStudentStudyLevel) 160 form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') -
main/waeup.fceokene/trunk/src/waeup/fceokene/students/interfaces.py
r14018 r14591 250 250 """ 251 251 252 total_credits_s1 = schema.Int( 253 title = _(u'1st Semester Credits'), 254 required = False, 255 ) 256 257 total_credits_s2 = schema.Int( 258 title = _(u'2nd Semester Credits'), 259 required = False, 260 ) 261 262 total_credits = schema.Int( 263 title = _(u'Total Credits'), 264 required = False, 265 ) 266 252 267 class ICustomStudentOnlinePayment(ICustomOnlinePayment): 253 268 """A student payment via payment gateways. -
main/waeup.fceokene/trunk/src/waeup/fceokene/students/studylevel.py
r14408 r14591 52 52 grok.provides(ICustomStudentStudyLevel) 53 53 54 @property 55 def total_credits_s1(self): 56 total = 0 57 for ticket in self.values(): 58 if ticket.semester == 1 and not ticket.outstanding: 59 total += ticket.credits 60 return total 61 62 @property 63 def total_credits_s2(self): 64 total = 0 65 for ticket in self.values(): 66 if ticket.semester == 2 and not ticket.outstanding: 67 total += ticket.credits 68 return total 69 54 70 CustomStudentStudyLevel = attrs_to_fields( 55 CustomStudentStudyLevel, omit=['total_credits', 'gpa']) 71 CustomStudentStudyLevel, omit=[ 72 'total_credits', 'total_credits_s1', 'total_credits_s2', 'gpa']) 56 73 57 74 class CustomStudentStudyLevelFactory(StudentStudyLevelFactory): -
main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_browser.py
r14406 r14591 29 29 from waeup.kofa.students.accommodation import BedTicket 30 30 from waeup.kofa.testing import FunctionalTestCase 31 from waeup.kofa.browser.tests.test_pdf import samples_dir 31 32 from waeup.kofa.interfaces import ( 32 33 IExtFileStore, IFileStoreNameChooser) … … 416 417 self.browser.contents) 417 418 return 419 420 def test_student_course_registration(self): 421 IWorkflowState(self.student).setState('school fee paid') 422 self.browser.open(self.login_path) 423 self.browser.getControl(name="form.login").value = self.student_id 424 self.browser.getControl(name="form.password").value = 'spwd' 425 self.browser.getControl("Login").click() 426 # Now students can add the current study level 427 self.browser.getLink("Study Course").click() 428 self.browser.getLink("Add course list").click() 429 self.assertMatches('...Add current level 100 (Year 1)...', 430 self.browser.contents) 431 self.browser.getControl("Create course list now").click() 432 # Students can't open the customized pdf course registration slip 433 self.browser.open( 434 self.student_path + '/studycourse/100/course_registration_slip.pdf') 435 self.assertEqual(self.browser.headers['Status'], '200 Ok') 436 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 437 path = os.path.join(samples_dir(), 'course_registration_slip.pdf') 438 open(path, 'wb').write(self.browser.contents) 439 print "Sample PDF course_registration_slip.pdf written to %s" % path -
main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_utils.py
r14586 r14591 31 31 return 32 32 33 def test_ maxCreditsExceeded(self):33 def test_warnCreditsOOR(self): 34 34 students_utils = getUtility(IStudentsUtils) 35 35 studylevel = grok.Container() 36 studylevel.total_credits = 40 36 studylevel.total_credits_s1 = 17 37 studylevel.total_credits_s2 = 17 37 38 course = grok.Model() 38 course.credits = 18 39 course.credits = 7 40 course.semester = 1 39 41 warning = students_utils.warnCreditsOOR(studylevel, course) 40 42 self.assertEqual(warning, None) 41 course.credits = 1943 course.credits = 8 42 44 warning = students_utils.warnCreditsOOR(studylevel, course) 43 self.assertEqual(warning, 'Maximum credits exceeded.') 45 self.assertEqual(warning, 'Maximum credits in 1st semester exceeded.') 46 course.semester = 2 47 warning = students_utils.warnCreditsOOR(studylevel, course) 48 self.assertEqual(warning, 'Maximum credits in 2nd semester exceeded.') 49 warning = students_utils.warnCreditsOOR(studylevel) 50 self.assertEqual(warning, 'Minimum credits in 1st semester not reached.') 51 studylevel.total_credits_s1 = 18 52 warning = students_utils.warnCreditsOOR(studylevel) 53 self.assertEqual(warning, 'Minimum credits in 2nd semester not reached.') 44 54 return 45 55 -
main/waeup.fceokene/trunk/src/waeup/fceokene/students/utils.py
r14586 r14591 362 362 363 363 def warnCreditsOOR(self, studylevel, course=None): 364 """Return message if credits are out of range. In the base 365 package only maximum credits is set. 366 """ 367 if course and studylevel.total_credits + course.credits > 58: 368 return _('Maximum credits exceeded.') 369 elif studylevel.total_credits > 58: 370 return _('Maximum credits exceeded.') 364 """Return message if credits are out of range. 365 """ 366 # adding a course ticket 367 if course: 368 if course.semester == 1: 369 if studylevel.total_credits_s1 + course.credits > 24: 370 return _('Maximum credits in 1st semester exceeded.') 371 if course.semester == 2: 372 if studylevel.total_credits_s2 + course.credits > 24: 373 return _('Maximum credits in 2nd semester exceeded.') 374 # registering course list 375 else: 376 if studylevel.total_credits_s1 > 24: 377 return _('Maximum credits in 1st semester exceeded.') 378 if studylevel.total_credits_s1 < 18: 379 return _('Minimum credits in 1st semester not reached.') 380 if studylevel.total_credits_s2 > 24: 381 return _('Maximum credits in 2nd semester exceeded.') 382 if studylevel.total_credits_s2 < 18: 383 return _('Minimum credits in 2nd semester not reached.') 371 384 return 372 385
Note: See TracChangeset for help on using the changeset viewer.