Ignore:
Timestamp:
11 May 2012, 16:32:07 (13 years ago)
Author:
Henrik Bettermann
Message:

Use same technique for approval of payments in students and in applicants.

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

Legend:

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

    r8420 r8422  
    599599
    600600    def update(self):
    601         self.wf_info = IWorkflowInfo(self.context.__parent__)
    602         try:
    603             self.wf_info.fireTransition('pay')
    604         except InvalidTransitionError:
    605             self.flash('Error: %s' % sys.exc_info()[1])
    606             return
    607         self.context.approve()
    608         ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    609         self.context.__parent__.loggerInfo(
    610             ob_class, 'valid callback: %s' % self.context.p_id)
    611         self.flash(_('Valid callback received.'))
     601        success, msg = self.context.approveApplicantPayment()
     602        if success:
     603            ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
     604            self.context.__parent__.loggerInfo(
     605                ob_class, 'valid callback: %s' % self.context.p_id)
     606        self.flash(msg)
    612607        return
    613608
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r8388 r8422  
    517517
    518518    """
     519
     520    def doAfterApplicantPayment():
     521        """Process applicant after payment was made.
     522
     523        """
     524
     525    def approveApplicantPayment():
     526        """Approve payment and process applicant.
     527
     528        """
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/payment.py

    r8260 r8422  
    2020"""
    2121import grok
     22from hurry.workflow.interfaces import IWorkflowInfo
    2223from zope.component.interfaces import IFactory
    2324from zope.interface import implementedBy
     25from waeup.kofa.interfaces import MessageFactory as _
    2426from waeup.kofa.payments import OnlinePayment
    2527from waeup.kofa.applicants.interfaces import IApplicantOnlinePayment
     
    3537        super(ApplicantOnlinePayment, self).__init__()
    3638        return
     39
     40    def doAfterApplicantPayment(self):
     41        """Process applicant after payment was made.
     42        """
     43        wf_info = IWorkflowInfo(self.__parent__)
     44        try:
     45            wf_info.fireTransition('pay')
     46        except InvalidTransitionError:
     47            return False, 'Error: %s' % sys.exc_info()[1]
     48        return True, _('Valid callback received.')
     49
     50    def approveApplicantPayment(self):
     51        """Approve payment and process applicant.
     52        """
     53        if self.p_state == 'paid':
     54            return False, _('This ticket has already been paid.')
     55        self.approve()
     56        return self.doAfterApplicantPayment()
    3757
    3858ApplicantOnlinePayment = attrs_to_fields(ApplicantOnlinePayment)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r8420 r8422  
    510510        )
    511511
     512    def doAfterStudentPayment():
     513        """Process student after payment was made.
     514
     515        """
     516
    512517    def approveStudentPayment():
    513         """Approve payment and create respective activation codes.
     518        """Approve payment and process student.
    514519
    515520        """
  • main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py

    r8420 r8422  
    6060            return None
    6161
    62     def approveStudentPayment(self):
    63         """Approve payment and create respective activation code.
     62    def doAfterStudentPayment(self):
     63        """Process student after payment was made.
    6464        """
    65         if self.p_state == 'paid':
    66             return False, _('This ticket has already been paid.')
    6765        student = self.getStudent()
    68         self.approve()
    6966        if self.p_category == 'clearance':
    7067            # Create CLR access code
     
    9390        return True, _('Valid callback received.')
    9491
     92    def approveStudentPayment(self):
     93        """Approve payment and process student.
     94        """
     95        if self.p_state == 'paid':
     96            return False, _('This ticket has already been paid.')
     97        self.approve()
     98        return self.doAfterStudentPayment()
     99
     100
    95101StudentOnlinePayment = attrs_to_fields(StudentOnlinePayment)
    96102
Note: See TracChangeset for help on using the changeset viewer.