Ignore:
Timestamp:
7 Dec 2012, 08:41:19 (12 years ago)
Author:
Henrik Bettermann
Message:

Use classes defined in kofacustom.nigeria.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/browser.py

    r9780 r9784  
    1919import grok
    2020from zope.component import getUtility
    21 from kofacustom.nigeria.interswitch.helpers import (
    22     query_interswitch, write_payments_log)
    23 from waeup.kofa.browser.layout import KofaPage, UtilityView
     21from kofacustom.nigeria.interswitch.browser import (
     22    InterswitchPaymentRequestWebservicePageApplicant,
     23    InterswitchPaymentRequestWebservicePageStudent
     24    )
     25from waeup.kofa.browser.layout import KofaPage
    2426from waeup.kofa.interfaces import IKofaUtils
    2527from waeup.kofa.utils.helpers import to_timezone
    26 from waeup.kofa.students.viewlets import ApprovePaymentActionButton as APABStudent
    27 from waeup.kofa.applicants.viewlets import ApprovePaymentActionButton as APABApplicant
    2828from waeup.fceokene.students.interfaces import ICustomStudentOnlinePayment
    2929from waeup.fceokene.applicants.interfaces import ICustomApplicantOnlinePayment
     
    4848#URL = '/test_paydirect/services/TransactionQueryWs.asmx'
    4949httplib.HTTPConnection.debuglevel = 0
    50 
    51 class InterswitchActionButtonStudent(APABStudent):
    52     grok.order(1)
    53     grok.context(ICustomStudentOnlinePayment)
    54     grok.require('waeup.payStudent')
    55     icon = 'actionicon_pay.png'
    56     text = _('CollegePAY')
    57     target = 'goto_interswitch'
    58 
    59     @property
    60     def target_url(self):
    61         if self.context.p_state != 'unpaid':
    62             return ''
    63         return self.view.url(self.view.context, self.target)
    64 
    65 class InterswitchActionButtonApplicant(APABApplicant):
    66     grok.order(1)
    67     grok.context(ICustomApplicantOnlinePayment)
    68     grok.require('waeup.payApplicant')
    69     icon = 'actionicon_pay.png'
    70     text = _('CollegePAY')
    71     target = 'goto_interswitch'
    72 
    73     @property
    74     def target_url(self):
    75         if self.context.p_state != 'unpaid':
    76             return ''
    77         return self.view.url(self.view.context, self.target)
    78 
    79 class InterswitchRequestWebserviceActionButtonStudent(APABStudent):
    80     grok.order(2)
    81     grok.context(ICustomStudentOnlinePayment)
    82     grok.require('waeup.payStudent')
    83     icon = 'actionicon_call.png'
    84     text = _('Requery CollegePAY')
    85     target = 'request_webservice'
    86 
    87 class InterswitchRequestWebserviceActionButtonApplicant(APABApplicant):
    88     grok.order(2)
    89     grok.context(ICustomApplicantOnlinePayment)
    90     grok.require('waeup.payApplicant')
    91     icon = 'actionicon_call.png'
    92     text = _('Requery CollegePAY')
    93     target = 'request_webservice'
    9450
    9551class InterswitchPageStudent(KofaPage):
     
    256212
    257213
    258 class InterswitchPaymentRequestWebservicePageStudent(UtilityView, grok.View):
     214class InterswitchPaymentRequestWebservicePageStudent(
     215    InterswitchPaymentRequestWebservicePageStudent):
    259216    """ Request webservice view for the CollegePAY gateway
    260217    """
    261218    grok.context(ICustomStudentOnlinePayment)
    262     grok.name('request_webservice')
    263     grok.require('waeup.payStudent')
    264 
    265     def update(self):
    266         if self.context.p_state == 'paid':
    267             self.flash(_('This ticket has already been paid.'))
    268             return
    269         student = self.context.student
    270         success, msg, log = query_interswitch(
    271             self.context, PRODUCT_ID, HOST, URL)
    272         student.writeLogMessage(self, log)
    273         if not success:
    274             self.flash(msg)
    275             return
    276         write_payments_log(student.student_id, self.context)
    277         success, msg, log = self.context.doAfterStudentPayment()
    278         if log is not None:
    279             student.writeLogMessage(self, log)
    280         self.flash(msg)
    281         return
    282 
    283     def render(self):
    284         self.redirect(self.url(self.context, '@@index'))
    285         return
    286 
    287 class InterswitchPaymentRequestWebservicePageApplicant(UtilityView, grok.View):
     219    product_id = PRODUCT_ID
     220    gateway_host = HOST
     221    gateway_url = URL
     222
     223class InterswitchPaymentRequestWebservicePageApplicant(
     224    InterswitchPaymentRequestWebservicePageApplicant):
    288225    """ Request webservice view for the CollegePAY gateway
    289226    """
    290227    grok.context(ICustomApplicantOnlinePayment)
    291     grok.name('request_webservice')
    292     grok.require('waeup.payApplicant')
    293 
    294     def update(self):
    295         if self.context.p_state == 'paid':
    296             self.flash(_('This ticket has already been paid.'))
    297             return
    298         applicant = self.context.__parent__
    299         success, msg, log = query_interswitch(
    300             self.context, PRODUCT_ID, HOST, URL)
    301         applicant.writeLogMessage(self, log)
    302         if not success:
    303             self.flash(msg)
    304             return
    305         write_payments_log(applicant.applicant_id, self.context)
    306         success, msg, log = self.context.doAfterApplicantPayment()
    307         if log is not None:
    308             applicant.writeLogMessage(self, log)
    309         self.flash(msg)
    310         return
    311 
    312     def render(self):
    313         self.redirect(self.url(self.context, '@@index'))
    314         return
     228    product_id = PRODUCT_ID
     229    gateway_host = HOST
     230    gateway_url = URL
Note: See TracChangeset for help on using the changeset viewer.