Changeset 8524


Ignore:
Timestamp:
26 May 2012, 05:42:39 (12 years ago)
Author:
Henrik Bettermann
Message:

Determine application fee and set payment attributes in ApplicantsUtility?.setPaymentDetails.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r8434 r8524  
    2222import sys
    2323import grok
    24 from time import time
    2524from datetime import datetime, date
    2625from zope.event import notify
     
    534533    factory = u'waeup.ApplicantOnlinePayment'
    535534
    536     def _fillCustomFields(self, payment, session_config):
    537         """No custom fields in the base package
    538         """
    539         return payment
    540 
    541535    def update(self):
    542         p_category = 'application'
    543         session = str(self.context.__parent__.year)
    544         try:
    545             session_config = grok.getSite()['configuration'][session]
    546         except KeyError:
    547             self.flash(_('Session configuration object is not available.'))
    548             self.redirect(self.url(self.context))
    549             return
    550         timestamp = "%d" % int(time()*1000)
    551536        for key in self.context.keys():
    552537            ticket = self.context[key]
     
    556541                  self.redirect(self.url(self.context))
    557542                  return
     543        applicants_utils = getUtility(IApplicantsUtils)
     544        container = self.context.__parent__
    558545        payment = createObject(self.factory)
    559         payment.p_id = "p%s" % timestamp
    560         payment.p_item = self.context.__parent__.title
    561         payment.p_session = self.context.__parent__.year
    562         payment.p_category = p_category
    563         payment.amount_auth = session_config.application_fee
    564         payment = self._fillCustomFields(payment, session_config)
     546        error = applicants_utils.setPaymentDetails(container, payment)
     547        if error is not None:
     548            self.flash(error)
     549            self.redirect(self.url(self.context))
     550            return
    565551        self.context[payment.p_id] = payment
    566552        self.flash(_('Payment ticket created.'))
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r8420 r8524  
    8787        applicantscontainer.prefix = 'app'
    8888        applicantscontainer.year = 2009
     89        applicantscontainer.title = u'This is the app2009 container'
    8990        applicantscontainer.application_category = 'basic'
    9091        applicantscontainer.mode = 'create'
     
    692693                           self.browser.contents)
    693694        payment_url = self.browser.url
     695        payment_id = self.applicant.keys()[0]
     696        payment = self.applicant[payment_id]
     697        self.assertEqual(payment.p_item,'This is the app2009 container')
     698        self.assertEqual(payment.p_session,2009)
     699        self.assertEqual(payment.p_category,'application')
     700        self.assertEqual(payment.amount_auth,200.0)
    694701        # The pdf payment slip can't yet be opened
    695702        #self.browser.open(payment_url + '/payment_receipt.pdf')
     
    701708            Unauthorized, self.browser.open, payment_url + '/approve')
    702709        # We approve the payment by bypassing the view
    703         payment_id = self.applicant.keys()[0]
    704         payment = self.applicant[payment_id]
    705710        payment.approve()
    706711        # The payment slip can be downloaded now
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py

    r8046 r8524  
    1919"""
    2020
     21from time import time
    2122import grok
    2223from waeup.kofa.applicants.interfaces import IApplicantsUtils
     
    3637      'form.screening_score': _(u'Process Data'),
    3738      }
     39
     40    def setPaymentDetails(self, container, payment):
     41        """Set the payment data of an applicant.
     42        """
     43        timestamp = "%d" % int(time()*1000)
     44        session = str(container.year)
     45        try:
     46            session_config = grok.getSite()['configuration'][session]
     47        except KeyError:
     48            return _(u'Session configuration object is not available.')
     49        payment.p_id = "p%s" % timestamp
     50        payment.p_item = container.title
     51        payment.p_session = container.year
     52        payment.p_category = 'application'
     53        payment.amount_auth = session_config.application_fee
     54        return None
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r8481 r8524  
    253253
    254254    def getPaymentDetails(self, category, student):
    255         """Get the payment dates of a student for the payment category
     255        """Get the payment data of a student for the payment category
    256256        specified.
    257257        """
Note: See TracChangeset for help on using the changeset viewer.