Changeset 12889


Ignore:
Timestamp:
27 Apr 2015, 08:14:31 (10 years ago)
Author:
Henrik Bettermann
Message:

Bypass school fee payment activation code creation if student is allowed
to proceed to next session.

Location:
main/waeup.kofa/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r12873 r12889  
    441.3.2.dev0 (unreleased)
    55=======================
     6
     7* Bypass school fee payment activation code creation if student is allowed
     8  to proceed to next session.
    69
    710* Convert level into a schema field to be consistent with the documentation.
  • main/waeup.kofa/trunk/docs/source/userdocs/datacenter/import_stages.rst

    r12883 r12889  
    5353(**import step 3**) by selecting the appropriate processor and an
    5454import mode. In import mode ``create`` new objects are added to the
    55 database, `in `update`` mode existing objects are modified and in
     55database, in ``update`` mode existing objects are modified and in
    5656``remove`` mode deleted.
    5757
  • main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py

    r11583 r12889  
    2222from zope.component.interfaces import IFactory
    2323from zope.interface import implementedBy
     24from zope.schema.interfaces import ConstraintNotSatisfied
     25from hurry.workflow.interfaces import IWorkflowInfo
    2426from waeup.kofa.interfaces import MessageFactory as _
    2527from waeup.kofa.students.interfaces import (
    2628    IStudentPaymentsContainer, IStudentNavigation, IStudentOnlinePayment)
     29from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID
    2730from waeup.kofa.payments import PaymentsContainer, OnlinePayment
    2831from waeup.kofa.payments.interfaces import IPayer
     
    6972        return self.__parent__.__parent__.writeLogMessage(view, message)
    7073
    71     def _createActivationCodes(self):
     74    def _redeemTicket(self):
    7275        student = self.student
    7376        if self.p_category == 'clearance':
     
    7982            self.ac = pin
    8083        elif self.p_category in ('schoolfee', 'schoolfee_1'):
     84            # Bypass activation code creation if next session
     85            # can be started directly.
     86            if student['studycourse'].next_session_allowed:
     87                try:
     88                    if student.state == CLEARED:
     89                        IWorkflowInfo(student).fireTransition(
     90                            'pay_first_school_fee')
     91                        return None
     92                    elif student.state == RETURNING:
     93                        IWorkflowInfo(student).fireTransition(
     94                            'pay_school_fee')
     95                        return None
     96                    elif student.state == PAID:
     97                        IWorkflowInfo(student).fireTransition(
     98                            'pay_pg_fee')
     99                        return None
     100                except ConstraintNotSatisfied:
     101                    pass
    81102            # Create SFE access code
    82103            pin, error = create_accesscode(
     
    105126        """
    106127        if self.p_current:
    107             error = self._createActivationCodes()
     128            error = self._redeemTicket()
    108129            if error is not None:
    109130                return 'danger', error, error
     
    117138        """
    118139        if self.p_current:
    119             error = self._createActivationCodes()
     140            error = self._redeemTicket()
    120141            if error is not None:
    121142                return 'danger', error, error
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r12854 r12889  
    929929        cat = queryUtility(ICatalog, name='payments_catalog')
    930930        results = list(cat.searchResults(p_state=('unpaid', 'unpaid')))
    931         self.assertTrue(len(results), 1)
     931        self.assertEqual(len(results), 2)
    932932        self.assertTrue(results[0] is self.student['payments'][value])
    933 
    934933        # Managers can approve the payment
     934        # If, by some reason, the state has already changed,
     935        # an access code is created after approval.
     936        IWorkflowState(self.student).setState('school fee paid')
    935937        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
    936938        self.browser.open(payment_url)
     
    951953            '"zope.mgr",K1000000,%s,schoolfee,40000.0,AP,,,,,,\n' % value
    952954            in logcontent)
    953 
    954         # The authorized amount has been stored in the access code
     955        # The authorized amount has been stored in the new access code
    955956        self.assertEqual(
    956957            self.app['accesscodes']['SFE-0'].values()[0].cost,40000.0)
     
    969970
    970971        # Now the first ticket is paid and no more ticket of same type
    971         # (with same p_item, p_session and p_category) can be added
     972        # (with same p_item, p_session and p_category) can be added.
     973        # First we have to reset the workflow state.
     974        IWorkflowState(self.student).setState('cleared')
    972975        self.browser.open(self.payments_path)
    973976        self.browser.getLink("Add current session payment ticket").click()
     
    10471050        self.assertEqual(ac.owner, self.student_id)
    10481051        self.assertEqual(ac.cost, 4567.0)
     1052        return
     1053
     1054    def test_manage_payments_bypass_ac_creation(self):
     1055        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1056        self.browser.open(self.payments_path)
     1057        IWorkflowState(self.student).setState('cleared')
     1058        self.browser.getLink("Add current session payment ticket").click()
     1059        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     1060        self.browser.getControl("Create ticket").click()
     1061        ctrl = self.browser.getControl(name='val_id')
     1062        value = ctrl.options[0]
     1063        self.browser.getLink(value).click()
     1064        payment_url = self.browser.url
     1065        logfile = os.path.join(
     1066            self.app['datacenter'].storage, 'logs', 'students.log')
     1067        # The ticket can be found in the payments_catalog
     1068        cat = queryUtility(ICatalog, name='payments_catalog')
     1069        results = list(cat.searchResults(p_state=('unpaid', 'unpaid')))
     1070        self.assertTrue(len(results), 1)
     1071        self.assertTrue(results[0] is self.student['payments'][value])
     1072        # Managers can approve the payment
     1073        self.browser.open(payment_url)
     1074        self.browser.getLink("Approve payment").click()
     1075        self.assertMatches('...Payment approved...',
     1076                          self.browser.contents)
     1077        # Approval is logged in students.log ...
     1078        logcontent = open(logfile).read()
     1079        self.assertTrue(
     1080            'zope.mgr - students.browser.OnlinePaymentApprovePage '
     1081            '- K1000000 - schoolfee payment approved'
     1082            in logcontent)
     1083        # ... and in payments.log
     1084        logfile = os.path.join(
     1085            self.app['datacenter'].storage, 'logs', 'payments.log')
     1086        logcontent = open(logfile).read()
     1087        self.assertTrue(
     1088            '"zope.mgr",K1000000,%s,schoolfee,40000.0,AP,,,,,,\n' % value
     1089            in logcontent)
     1090        # Student is in state school fee paid, no activation
     1091        # code was necessary.
     1092        self.assertEqual(self.student.state, 'school fee paid')
     1093        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
    10491094        return
    10501095
     
    27022747                          self.browser.contents)
    27032748
    2704         # The new SFE-0 pin can be used for starting new session
    2705         self.browser.open(self.studycourse_path)
    2706         self.browser.getLink('Start new session').click()
    2707         pin = self.app['accesscodes']['SFE-0'].keys()[0]
    2708         parts = pin.split('-')[1:]
    2709         sfeseries, sfenumber = parts
    2710         self.browser.getControl(name="ac_series").value = sfeseries
    2711         self.browser.getControl(name="ac_number").value = sfenumber
    2712         self.browser.getControl("Start now").click()
    2713         self.assertMatches('...Session started...',
    2714                            self.browser.contents)
     2749        ## The new SFE-0 pin can be used for starting new session
     2750        #self.browser.open(self.studycourse_path)
     2751        #self.browser.getLink('Start new session').click()
     2752        #pin = self.app['accesscodes']['SFE-0'].keys()[0]
     2753        #parts = pin.split('-')[1:]
     2754        #sfeseries, sfenumber = parts
     2755        #self.browser.getControl(name="ac_series").value = sfeseries
     2756        #self.browser.getControl(name="ac_number").value = sfenumber
     2757        #self.browser.getControl("Start now").click()
     2758        #self.assertMatches('...Session started...',
     2759        #                   self.browser.contents)
     2760
    27152761        self.assertTrue(self.student.state == 'school fee paid')
    27162762        return
     
    28742920                          self.browser.contents)
    28752921
    2876         # The new SFE-0 pin can be used for starting session
    2877         self.browser.open(self.studycourse_path)
    2878         self.browser.getLink('Start new session').click()
    2879         pin = self.app['accesscodes']['SFE-0'].keys()[0]
    2880         parts = pin.split('-')[1:]
    2881         sfeseries, sfenumber = parts
    2882         self.browser.getControl(name="ac_series").value = sfeseries
    2883         self.browser.getControl(name="ac_number").value = sfenumber
    2884         self.browser.getControl("Start now").click()
    2885         self.assertMatches('...Session started...',
    2886                            self.browser.contents)
     2922        ## The new SFE-0 pin can be used for starting session
     2923        #self.browser.open(self.studycourse_path)
     2924        #self.browser.getLink('Start new session').click()
     2925        #pin = self.app['accesscodes']['SFE-0'].keys()[0]
     2926        #parts = pin.split('-')[1:]
     2927        #sfeseries, sfenumber = parts
     2928        #self.browser.getControl(name="ac_series").value = sfeseries
     2929        #self.browser.getControl(name="ac_number").value = sfenumber
     2930        #self.browser.getControl("Start now").click()
     2931        #self.assertMatches('...Session started...',
     2932        #                   self.browser.contents)
     2933
    28872934        self.assertTrue(self.student.state == 'school fee paid')
    28882935
Note: See TracChangeset for help on using the changeset viewer.