Changeset 11635


Ignore:
Timestamp:
13 May 2014, 10:20:30 (11 years ago)
Author:
Henrik Bettermann
Message:

Use base classes InterswitchPageApplicant? and InterswitchPageStudent? from kofacustom.nigeria.

Location:
main/waeup.fceokene/trunk
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.fceokene/trunk/CHANGES.txt

    r11562 r11635  
    441.2dev (unreleased)
    55===================
     6
     7* Use base classes InterswitchPageApplicant and InterswitchPageStudent from
     8  kofacustom.nigeria.
    69
    710* File input fields brought into shape with Bootstrap 3.
  • main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/browser.py

    r10528 r11635  
    1818import httplib
    1919import grok
    20 from zope.component import getUtility
    2120from kofacustom.nigeria.interswitch.browser import (
    2221    InterswitchPaymentRequestWebservicePageApplicant,
    23     InterswitchPaymentRequestWebservicePageStudent
     22    InterswitchPaymentRequestWebservicePageStudent,
     23    InterswitchPageStudent, InterswitchPageApplicant,
    2424    )
    25 from waeup.kofa.browser.layout import KofaPage
    26 from waeup.kofa.interfaces import IKofaUtils
    27 from waeup.kofa.utils.helpers import to_timezone
    2825from waeup.fceokene.students.interfaces import ICustomStudentOnlinePayment
    2926from waeup.fceokene.applicants.interfaces import ICustomApplicantOnlinePayment
     
    4946httplib.HTTPConnection.debuglevel = 0
    5047
    51 class InterswitchPageStudent(KofaPage):
     48class CustomInterswitchPageStudent(InterswitchPageStudent):
    5249    """ View which sends a POST request to the Interswitch
    5350    CollegePAY payment gateway.
    5451    """
    5552    grok.context(ICustomStudentOnlinePayment)
    56     grok.name('goto_interswitch')
    57     grok.template('student_goto_interswitch')
    58     grok.require('waeup.payStudent')
    59     label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
    60     submit_button = _('Submit')
    6153    action = POST_ACTION
    6254    site_name = SITE_NAME
     
    6658
    6759    def update(self):
    68         if self.context.p_state == 'paid':
    69             self.flash(_("Payment ticket can't be re-send to CollegePAY."))
    70             self.redirect(self.url(self.context, '@@index'))
    71             return
    72 
    73         student = self.student = self.context.student
    74         certificate = getattr(student['studycourse'],'certificate',None)
    75         self.amount_auth = 100 * self.context.amount_auth
    76         xmldict = {}
    77         if certificate is not None:
    78             xmldict['department'] = certificate.__parent__.__parent__.code
    79             xmldict['faculty'] = certificate.__parent__.__parent__.__parent__.code
    80         else:
    81             xmldict['department'] = None
    82             xmldict['faculty'] = None
    83         self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
    84         tz = getUtility(IKofaUtils).tzinfo
    85         self.local_date_time = to_timezone(
    86             self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    87         self.site_redirect_url = self.url(self.context, 'request_webservice')
     60        student, certificate, xmldict = super(
     61            CustomInterswitchPageStudent, self).update()
    8862        # Provider data
    8963        provider_amt = 1600.0
     
    162136        return
    163137
    164 class InterswitchPageApplicant(KofaPage):
     138class CustomInterswitchPageApplicant(InterswitchPageApplicant):
    165139    """ View which sends a POST request to the Interswitch
    166140    CollegePAY payment gateway.
    167141    """
    168142    grok.context(ICustomApplicantOnlinePayment)
    169     grok.require('waeup.payApplicant')
    170     grok.template('applicant_goto_interswitch')
    171     grok.name('goto_interswitch')
    172     label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
    173     submit_button = _('Submit')
    174143    action = POST_ACTION
    175144    site_name = SITE_NAME
     
    179148
    180149    def update(self):
    181         if self.context.p_state != 'unpaid':
    182             self.flash(_("Payment ticket can't be re-send to CollegePAY."))
    183             self.redirect(self.url(self.context, '@@index'))
    184             return
    185         if self.context.__parent__.__parent__.expired \
    186             and self.context.__parent__.__parent__.strict_deadline:
    187             self.flash(_("Payment ticket can't be send to CollegePAY. "
    188                          "Application period has expired."))
    189             self.redirect(self.url(self.context, '@@index'))
    190             return
    191         self.applicant = self.context.__parent__
    192         self.amount_auth = 100 * self.context.amount_auth
     150        super(CustomInterswitchPageApplicant, self).update()
    193151        xmldict = {}
    194         self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
    195         tz = getUtility(IKofaUtils).tzinfo
    196         self.local_date_time = to_timezone(
    197             self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    198         self.site_redirect_url = self.url(self.context, 'request_webservice')
    199         xmldict['detail_ref'] = self.context.p_id
    200152        # Provider data
    201153        provider_amt = 500.0
     154        xmldict['detail_ref'] = self.context.p_id
    202155        xmldict['provider_amt'] = 100 * provider_amt
    203156        xmldict['provider_acct'] = PROVIDER_ACCT
     
    229182
    230183
    231 class InterswitchPaymentRequestWebservicePageStudent(
     184class CustomInterswitchPaymentRequestWebservicePageStudent(
    232185    InterswitchPaymentRequestWebservicePageStudent):
    233186    """ Request webservice view for the CollegePAY gateway
     
    238191    gateway_url = URL
    239192
    240 class InterswitchPaymentRequestWebservicePageApplicant(
     193class CustomInterswitchPaymentRequestWebservicePageApplicant(
    241194    InterswitchPaymentRequestWebservicePageApplicant):
    242195    """ Request webservice view for the CollegePAY gateway
  • main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/tests.py

    r10835 r11635  
    297297        self.assertTrue(
    298298            'zope.mgr - '
    299             'waeup.fceokene.interswitch.browser.InterswitchPaymentRequestWebservicePageStudent - '
     299            'waeup.fceokene.interswitch.browser.CustomInterswitchPaymentRequestWebservicePageStudent - '
    300300            'K1000000 - successful schoolfee payment: p3536651296379\n'
    301301            in logcontent)
     
    416416        self.assertTrue(
    417417            'zope.mgr - '
    418             'waeup.fceokene.interswitch.browser.InterswitchPaymentRequestWebservicePageApplicant - '
     418            'waeup.fceokene.interswitch.browser.CustomInterswitchPaymentRequestWebservicePageApplicant - '
    419419            '%s - successful payment: p3536651296379\n'
    420420            % self.applicant.applicant_id in logcontent)
Note: See TracChangeset for help on using the changeset viewer.