Ignore:
Timestamp:
11 May 2012, 14:18:47 (12 years ago)
Author:
Henrik Bettermann
Message:

Add methods for approving payments and implement pages for approving payments (work in progress).

File:
1 edited

Legend:

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

    r8404 r8420  
    3232from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    3333from waeup.kofa.accesscodes import (
    34     invalidate_accesscode, get_access_code, create_accesscode)
     34    invalidate_accesscode, get_access_code)
    3535from waeup.kofa.accesscodes.workflow import USED
    3636from waeup.kofa.browser import (
     
    11301130            'b':self.context.p_id})
    11311131
    1132 class OnlinePaymentCallbackPage(UtilityView, grok.View):
     1132class OnlinePaymentApprovePage(UtilityView, grok.View):
    11331133    """ Callback view
    11341134    """
    11351135    grok.context(IStudentOnlinePayment)
    1136     grok.name('simulate_callback')
    1137     grok.require('waeup.payStudent')
    1138 
    1139     # This update method simulates a valid callback und must be
    1140     # neutralized in the customization package.
     1136    grok.name('approve')
     1137    grok.require('waeup.managePortal')
     1138
    11411139    def update(self):
    1142         if self.context.p_state == 'paid':
    1143             self.flash(_('This ticket has already been paid.'))
    1144             return
    1145         student = self.context.getStudent()
    1146         write_log_message(self,'valid callback: %s' % self.context.p_id)
    1147         self.context.r_amount_approved = self.context.amount_auth
    1148         self.context.r_code = u'00'
    1149         self.context.p_state = 'paid'
    1150         self.context.payment_date = datetime.utcnow()
    1151         if self.context.p_category == 'clearance':
    1152             # Create CLR access code
    1153             pin, error = create_accesscode(
    1154                 'CLR',0,self.context.amount_auth,student.student_id)
    1155             if error:
    1156                 self.flash(_('Valid callback received. ${a}',
    1157                     mapping = {'a':error}))
    1158                 return
    1159             self.context.ac = pin
    1160         elif self.context.p_category == 'schoolfee':
    1161             # Create SFE access code
    1162             pin, error = create_accesscode(
    1163                 'SFE',0,self.context.amount_auth,student.student_id)
    1164             if error:
    1165                 self.flash(_('Valid callback received. ${a}',
    1166                     mapping = {'a':error}))
    1167                 return
    1168             self.context.ac = pin
    1169         elif self.context.p_category == 'bed_allocation':
    1170             # Create HOS access code
    1171             pin, error = create_accesscode(
    1172                 'HOS',0,self.context.amount_auth,student.student_id)
    1173             if error:
    1174                 self.flash(_('Valid callback received. ${a}',
    1175                     mapping = {'a':error}))
    1176                 return
    1177             self.context.ac = pin
    1178         self.flash(_('Valid callback received.'))
     1140        success, msg = self.context.approveStudentPayment()
     1141        if success:
     1142            write_log_message(self,'valid callback: %s' % self.context.p_id)
     1143        self.flash(msg)
    11791144        return
    11801145
     
    11821147        self.redirect(self.url(self.context, '@@index'))
    11831148        return
     1149
     1150class OnlinePaymentFakeApprovePage(OnlinePaymentApprovePage):
     1151    """ Approval view for students.
     1152
     1153    This view is used for browser tests only and
     1154    must be neutralized in custom pages!
     1155    """
     1156
     1157    grok.name('fake_approve')
     1158    grok.require('waeup.payStudent')
    11841159
    11851160class ExportPDFPaymentSlipPage(UtilityView, grok.View):
Note: See TracChangeset for help on using the changeset viewer.