Changeset 7025 for main


Ignore:
Timestamp:
8 Nov 2011, 06:21:19 (13 years ago)
Author:
Henrik Bettermann
Message:

The same payment ticket (with same p_item, p_session and p_category) must not be added twice.

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

Legend:

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

    r7024 r7025  
    926926                self.redirect(self.url(self.context))
    927927                return
     928        pay_details  = self.getPaymentDetails(
     929            p_category,student)
     930        if pay_details['error']:
     931            self.flash(pay_details['error'])
     932            self.redirect(self.url(self.context))
     933            return
     934        p_item = pay_details['p_item']
     935        p_session = pay_details['p_session']
     936        for key in self.context.keys():
     937            ticket = self.context[key]
     938            if ticket.p_category == p_category and \
     939               ticket.p_item == p_item and \
     940               ticket.p_session == p_session:
     941                  self.flash(
     942                      'This payment ticket already exists.')
     943                  self.redirect(self.url(self.context))
     944                  return
    928945        payment = createObject(u'waeup.StudentOnlinePayment')
    929946        self.applyData(payment, **data)
     
    931948        #order_id = "%s%s" % (student_id[1:],timestamp)
    932949        payment.p_id = "p%s" % timestamp
    933         pay_details  = self.getPaymentDetails(
    934             p_category,student)
    935         if pay_details['error']:
    936             self.flash(pay_details['error'])
    937             self.redirect(self.url(self.context))
    938             return
     950        payment.p_item = p_item
     951        payment.p_session = p_session
    939952        payment.amount_auth = pay_details['amount']
    940         payment.p_item = pay_details['p_item']
    941         payment.p_session = pay_details['p_session']
    942953        payment.surcharge_1 = pay_details['surcharge_1']
    943954        payment.surcharge_2 = pay_details['surcharge_2']
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7024 r7025  
    685685    def test_manage_payments(self):
    686686        # Managers can add online school fee payment tickets
     687        # if certain requirements are met
    687688        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    688689        self.browser.open(self.payments_student_path)
     
    698699                           self.browser.contents)
    699700        payment_url = self.browser.url
     701
     702        # The same payment ticket (with same p_item, p_session and p_category)
     703        # can't be added twice.
     704        self.browser.open(self.payments_student_path)
     705        self.browser.getControl("Add online payment ticket").click()
     706        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     707        self.browser.getControl("Create ticket").click()
     708        self.assertMatches('...This payment ticket already exists...',
     709                           self.browser.contents)
     710
    700711        # Managers can open the callback view which simulates a valid callback
    701712        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
Note: See TracChangeset for help on using the changeset viewer.