Changeset 15330 for main/waeup.aaue/trunk/src
- Timestamp:
- 14 Feb 2019, 15:55:27 (6 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/interfaces.py
r15181 r15330 302 302 ) 303 303 304 studylevel_repair_enabled = schema.Bool( 305 title = _(u'Course list repair enabled'), 306 description = _(u'If set, students will be able to add and delete courses.'), 307 default = False, 308 required = False, 309 ) 310 304 311 305 312 def getSessionString(): -
main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
r15317 r15330 29 29 from zope.formlib.textwidgets import BytesDisplayWidget 30 30 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 31 from waeup.kofa.browser.layout import UtilityView 31 from waeup.kofa.browser.layout import UtilityView, KofaEditFormPage, jsaction 32 32 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget 33 33 from waeup.kofa.interfaces import ( 34 34 IKofaUtils, academic_sessions_vocab, ICSVExporter, IKofaObject) 35 35 from waeup.kofa.students.interfaces import ( 36 IStudentsUtils, IStudent, IStudentRequestPW )36 IStudentsUtils, IStudent, IStudentRequestPW, IStudentStudyLevel) 37 37 from waeup.kofa.students.workflow import PAID, REGISTERED, RETURNING 38 38 from waeup.kofa.students.browser import ( … … 56 56 StudentRequestPasswordPage, 57 57 StudyCourseManageFormPage, 58 UnregisterCoursesView 58 UnregisterCoursesView, 59 addCourseTicket, 60 emit_lock_message 59 61 ) 60 62 from kofacustom.nigeria.students.browser import ( … … 391 393 'Student ID Card Fee, ' 392 394 'Student Union Dues, ' 395 'Sports Fee, ' 396 'Library Levy, ' 393 397 'Student Welfare Assurance Fee and ') 394 398 else: … … 401 405 text += ('School Fee, ' 402 406 'Student Union Dues, ' 407 'Sports Development Fee, ' 408 'Library Development Levy, ' 403 409 'Student Welfare Assurance Fee and ') 404 410 elif self.context.p_category in ( … … 512 518 """ 513 519 grok.context(ICustomStudentStudyLevel) 520 521 class StudyLevelRepairFormPage(KofaEditFormPage): 522 """ Page to repair the student study level data by students 523 """ 524 grok.context(IStudentStudyLevel) 525 grok.name('repair') 526 grok.require('waeup.editStudyLevel') 527 grok.template('studylevelrepairpage') 528 pnav = 4 529 placeholder = _('Enter valid course code') 530 531 def update(self, ADD=None, course=None): 532 try: 533 studylevel_repair_enabled = grok.getSite()['configuration'][ 534 str(self.context.level_session)].studylevel_repair_enabled 535 except KeyError: 536 emit_lock_message(self) 537 return 538 if not studylevel_repair_enabled: 539 emit_lock_message(self) 540 return 541 super(StudyLevelRepairFormPage, self).update() 542 if ADD is not None: 543 if not course: 544 self.flash(_('No valid course code entered.'), type="warning") 545 return 546 cat = queryUtility(ICatalog, name='courses_catalog') 547 result = cat.searchResults(code=(course, course)) 548 if len(result) != 1: 549 self.flash(_('Course not found.'), type="warning") 550 return 551 course = list(result)[0] 552 addCourseTicket(self, course) 553 return 554 555 @property 556 def label(self): 557 # Here we know that the cookie has been set 558 lang = self.request.cookies.get('kofa.language') 559 level_title = translate(self.context.level_title, 'waeup.kofa', 560 target_language=lang) 561 return _('Repair course list of ${a}', 562 mapping = {'a':level_title}) 563 564 @property 565 def translated_values(self): 566 return translated_values(self) 567 568 def _delCourseTicket(self, **data): 569 form = self.request.form 570 if 'val_id' in form: 571 child_id = form['val_id'] 572 else: 573 self.flash(_('No ticket selected.'), type="warning") 574 self.redirect(self.url(self.context, '@@edit')) 575 return 576 if not isinstance(child_id, list): 577 child_id = [child_id] 578 deleted = [] 579 for id in child_id: 580 # Students are not allowed to remove core tickets 581 if id in self.context and \ 582 self.context[id].removable_by_student: 583 del self.context[id] 584 deleted.append(id) 585 if len(deleted): 586 self.flash(_('Successfully removed: ${a}', 587 mapping = {'a':', '.join(deleted)})) 588 self.context.writeLogMessage( 589 self,'removed: %s at %s' % 590 (', '.join(deleted), self.context.level)) 591 self.redirect(self.url(self.context, u'@@repair')) 592 return 593 594 @jsaction(_('Remove selected tickets')) 595 def delCourseTicket(self, **data): 596 self._delCourseTicket(**data) 597 return 514 598 515 599 class CustomExportPDFCourseRegistrationSlip( -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r15317 r15330 1081 1081 return 1082 1082 1083 def test_repair_course_list(self): 1084 IWorkflowState(self.student).setState('school fee paid') 1085 self.student['studycourse'].entry_session = 2016 1086 self.student['studycourse'].current_session = 2016 1087 self.browser.open(self.login_path) 1088 self.browser.getControl(name="form.login").value = self.student_id 1089 self.browser.getControl(name="form.password").value = 'spwd' 1090 self.browser.getControl("Login").click() 1091 self.browser.getLink("Study Course").click() 1092 self.browser.getLink("Add course list").click() 1093 self.browser.getControl("Create course list now").click() 1094 self.assertTrue('Edit course list' in self.browser.contents) 1095 self.assertFalse('Repair course list' in self.browser.contents) 1096 self.student['studycourse'].current_level = 200 1097 self.browser.open(self.studycourse_path + '/100') 1098 self.assertFalse('Edit course list' in self.browser.contents) 1099 self.assertFalse('Repair course list' in self.browser.contents) 1100 configuration = createObject('waeup.SessionConfiguration') 1101 configuration.academic_session = 2016 1102 self.app['configuration'].addSessionConfiguration(configuration) 1103 self.app['configuration']['2016'].studylevel_repair_enabled = True 1104 self.browser.open(self.studycourse_path + '/100') 1105 self.assertFalse('Edit course list' in self.browser.contents) 1106 self.assertTrue('Repair course list' in self.browser.contents) 1107 self.browser.getLink("Repair").click() 1108 self.assertEqual(self.browser.url, self.studycourse_path + '/100/repair') 1109 self.assertTrue('Repair course list of 100' in self.browser.contents) 1110 return 1111 1083 1112 def test_student_clearance(self): 1084 1113 # Student cant login if their password is not set -
main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py
r14661 r15330 20 20 from zope.component import getUtility 21 21 from waeup.kofa.interfaces import REGISTERED 22 from waeup.kofa.students.interfaces import IStudent, IStudentsUtils 22 from waeup.kofa.students.interfaces import ( 23 IStudent, IStudentsUtils, IStudentStudyLevel) 23 24 from waeup.kofa.students.workflow import PAID 24 25 from waeup.kofa.students.viewlets import ( … … 168 169 return '' 169 170 return self.view.url(self.view.context, 'coursetickets.pdf') 171 172 class StudyLevelRepairActionButton(ManageActionButton): 173 grok.order(2) 174 grok.context(IStudentStudyLevel) 175 grok.view(StudyLevelDisplayFormPage) 176 grok.require('waeup.editStudyLevel') 177 text = _('Repair course list') 178 target = 'repair' 179 icon = 'actionicon_repair1.png' 180 181 @property 182 def target_url(self): 183 try: 184 studylevel_repair_enabled = grok.getSite()['configuration'][ 185 str(self.context.level_session)].studylevel_repair_enabled 186 except KeyError: 187 return '' 188 if not studylevel_repair_enabled: 189 return '' 190 return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.