Ignore:
Timestamp:
15 Jun 2012, 11:09:58 (13 years ago)
Author:
Henrik Bettermann
Message:

Re-use code.

Fix approveStudentPayment and adjust tests.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py

    r8708 r8732  
    6161            return None
    6262
    63     def doAfterStudentPayment(self):
    64         """Process student after payment was made.
    65         """
     63    def _createActivationCodes(self):
    6664        student = self.getStudent()
    6765        if self.p_category == 'clearance':
     
    7068                'CLR',0,self.amount_auth,student.student_id)
    7169            if error:
    72                 return False, error, error
     70                return error
    7371            self.ac = pin
    74         elif self.p_category == 'schoolfee':
     72        elif self.p_category in ('schoolfee', 'schoolfee_1'):
    7573            # Create SFE access code
    7674            pin, error = create_accesscode(
    7775                'SFE',0,self.amount_auth,student.student_id)
    7876            if error:
    79                 return False, error, error
     77                return error
    8078            self.ac = pin
    8179        elif self.p_category == 'bed_allocation':
     
    8482                'HOS',0,self.amount_auth,student.student_id)
    8583            if error:
    86                 return False, error, error
     84                return error
    8785            self.ac = pin
     86        return None
     87
     88    def doAfterStudentPayment(self):
     89        """Process student after payment was made.
     90        """
     91        error = self._createActivationCodes()
     92        if error is not None:
     93            return False, error, error
    8894        log = 'successful payment: %s' % self.p_id
    8995        msg = _('Successful payment')
     
    9399        """Process student after payment was approved.
    94100        """
    95         student = self.getStudent()
    96         if self.p_category == 'clearance':
    97             # Create CLR access code
    98             pin, error = create_accesscode(
    99                 'CLR',0,self.amount_auth,student.student_id)
    100             if error:
    101                 return False, error, error
    102             self.ac = pin
    103         elif self.p_category == 'schoolfee':
    104             # Create SFE access code
    105             pin, error = create_accesscode(
    106                 'SFE',0,self.amount_auth,student.student_id)
    107             if error:
    108                 return False, error, error
    109             self.ac = pin
    110         elif self.p_category == 'bed_allocation':
    111             # Create HOS access code
    112             pin, error = create_accesscode(
    113                 'HOS',0,self.amount_auth,student.student_id)
    114             if error:
    115                 return False, error, error
    116             self.ac = pin
     101        error = self._createActivationCodes()
     102        if error is not None:
     103            return False, error, error
    117104        log = 'payment approved: %s' % self.p_id
    118105        msg = _('Payment approved')
     
    125112            return False, _('This ticket has already been paid.'), None
    126113        self.approve()
    127         return self.doAfterStudentPayment()
     114        return self.doAfterStudentPaymentApproval()
    128115
    129116
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r8708 r8732  
    13121312        self.browser.open(payment_url)
    13131313        self.browser.getLink("Approve payment").click()
    1314         self.assertMatches('...Successful payment...',
     1314        self.assertMatches('...Payment approved...',
    13151315                          self.browser.contents)
    13161316
     
    13631363        self.browser.getLink(value).click()
    13641364        self.browser.open(self.browser.url + '/approve')
    1365         self.assertMatches('...Successful payment...',
     1365        self.assertMatches('...Payment approved...',
    13661366                          self.browser.contents)
    13671367        expected = '''...
     
    14021402        # In the base package they can 'use' a fake approval view
    14031403        self.browser.open(payment_url + '/fake_approve')
    1404         self.assertMatches('...Successful payment...',
     1404        self.assertMatches('...Payment approved...',
    14051405                          self.browser.contents)
    14061406        expected = '''...
     
    14841484        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
    14851485        self.browser.open(self.browser.url + '/fake_approve')
    1486         self.assertMatches('...Successful payment...',
     1486        self.assertMatches('...Payment approved...',
    14871487                          self.browser.contents)
    14881488
     
    15481548        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
    15491549        self.browser.open(self.browser.url + '/fake_approve')
    1550         self.assertMatches('...Successful payment...',
     1550        self.assertMatches('...Payment approved...',
    15511551                          self.browser.contents)
    15521552
Note: See TracChangeset for help on using the changeset viewer.