Ignore:
Timestamp:
3 Oct 2012, 07:08:02 (12 years ago)
Author:
Henrik Bettermann
Message:

Customize _registerCourses. This customized version does allow 'special postgraduate' students to register their courses.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r9251 r9281  
    1919from zope.i18n import translate
    2020from zope.schema.interfaces import ConstraintNotSatisfied
     21from hurry.workflow.interfaces import IWorkflowInfo
    2122from waeup.kofa.interfaces import REQUESTED
    2223from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    2324from waeup.kofa.browser.layout import KofaEditFormPage
    2425from waeup.kofa.browser.viewlets import ManageActionButton
    25 from waeup.kofa.browser.layout import action
     26from waeup.kofa.browser.layout import action, jsaction
    2627from waeup.kofa.students.browser import (
    2728    StudentClearPage, StudentRejectClearancePage,
    28     StudyCourseDisplayFormPage, msave, emit_lock_message)
     29    StudyCourseDisplayFormPage,
     30    StudyLevelEditFormPage,
     31    msave, emit_lock_message)
    2932from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
    3033from kofacustom.nigeria.students.browser import (
     
    3235    NigeriaStudentBaseManageFormPage,
    3336    NigeriaOnlinePaymentAddFormPage,
    34     NigeriaExportPDFPaymentSlipPage)
     37    NigeriaExportPDFPaymentSlipPage,
     38    )
    3539#from waeup.uniben.students.interfaces import ICustomStudent
    3640
     
    117121
    118122class StudyCourseCOEditFormPage(KofaEditFormPage):
    119     """ Page to edit the student study course data by clearance officers
     123    """ Page to edit the student study course data by clearance officers.
    120124
    121125    This form page is available only in Uniben.
     
    147151        #notify(grok.ObjectModifiedEvent(self.context.__parent__))
    148152        return
     153
     154class CustomStudyLevelEditFormPage(StudyLevelEditFormPage):
     155    """ Page to edit the student study level data by students.
     156
     157    """
     158
     159    def _registerCourses(self, **data):
     160        """ This customized version does allow 'special postgraduate'
     161        students to register their courses.
     162        """
     163        if self.context.student.is_postgrad and \
     164            not self.context.student.is_special_postgrad:
     165            self.flash(_(
     166                "You are a postgraduate student, "
     167                "your course list can't bee registered."))
     168            self.redirect(self.url(self.context))
     169            return
     170        if self.total_credits > self.max_credits:
     171            self.flash(_('Maximum credits of ${a} exceeded.',
     172                mapping = {'a':self.max_credits}))
     173            return
     174        IWorkflowInfo(self.context.student).fireTransition(
     175            'register_courses')
     176        self.flash(_('Course list has been registered.'))
     177        self.redirect(self.url(self.context))
     178        return
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r9251 r9281  
    487487        self.assertMatches('...has been saved...', self.browser.contents)
    488488        self.assertEqual(self.student.current_level, 200)
     489
     490    def test_postgraduate_student_access(self):
     491        self.certificate.study_mode = 'special_pg_pt'
     492        self.certificate.start_level = 700
     493        self.certificate.end_level = 800
     494        self.student['studycourse'].current_level = 700
     495        IWorkflowState(self.student).setState('school fee paid')
     496        self.browser.open(self.login_path)
     497        self.browser.getControl(name="form.login").value = self.student_id
     498        self.browser.getControl(name="form.password").value = 'spwd'
     499        self.browser.getControl("Login").click()
     500        self.assertTrue(
     501            'You logged in.' in self.browser.contents)
     502        # Now students can add the current study level
     503        self.browser.getLink("Study Course").click()
     504        self.browser.getLink("Add course list").click()
     505        self.assertMatches('...Add current level 700...',
     506                           self.browser.contents)
     507        self.browser.getControl("Create course list now").click()
     508        # A level with one course ticket was created
     509        self.assertEqual(self.student['studycourse']['700'].number_of_tickets, 0)
     510        self.browser.getLink("700").click()
     511        self.browser.getLink("Edit course list").click()
     512        self.browser.getControl("Add course ticket").click()
     513        self.browser.getControl(name="form.course").value = ['COURSE1']
     514        self.browser.getControl("Add course ticket").click()
     515        self.assertMatches('...Successfully added COURSE1...',
     516                           self.browser.contents)
     517        # Special postgraduate students can register course lists
     518        self.browser.getControl("Register course list").click()
     519        self.assertMatches('...Course list has been registered...',
     520            self.browser.contents)
     521        self.assertEqual(self.student.state, 'courses registered')
     522        return
Note: See TracChangeset for help on using the changeset viewer.