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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.skeleton/trunk/src/kofacustom/skeleton/interswitch/browser.py

    r10765 r11638  
    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 kofacustom.skeleton.students.interfaces import ICustomStudentOnlinePayment
    2926from kofacustom.skeleton.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
     
    6557
    6658    def update(self):
    67         #if self.context.p_state != 'unpaid':
    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         if certificate is None:
    76             self.flash(_("Study course data are incomplete."))
    77             self.redirect(self.url(self.context, '@@index'))
    78             return
    79         self.amount_auth = 100 * self.context.amount_auth
    80         xmldict = {}
    81         if certificate is not None:
    82             xmldict['department'] = certificate.__parent__.__parent__.code
    83             xmldict['faculty'] = certificate.__parent__.__parent__.__parent__.code
    84         else:
    85             xmldict['department'] = None
    86             xmldict['faculty'] = None
    87         self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
    88         tz = getUtility(IKofaUtils).tzinfo
    89         self.local_date_time = to_timezone(
    90             self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    91         self.site_redirect_url = self.url(self.context, 'request_webservice')
     59        student, certificate, xmldict = super(
     60            CustomInterswitchPageStudent, self).update()
    9261        # Provider data
    9362        xmldict['detail_ref'] = self.context.p_id
     
    12594        return
    12695
    127 class InterswitchPageApplicant(KofaPage):
     96class CustomInterswitchPageApplicant(InterswitchPageApplicant):
    12897    """ View which sends a POST request to the Interswitch
    12998    CollegePAY payment gateway.
    13099    """
    131100    grok.context(ICustomApplicantOnlinePayment)
    132     grok.require('waeup.payApplicant')
    133     grok.template('applicant_goto_interswitch')
    134     grok.name('goto_interswitch')
    135     label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
    136     submit_button = _('Submit')
    137101    action = POST_ACTION
    138102    site_name = SITE_NAME
     
    142106
    143107    def update(self):
    144         if self.context.p_state != 'unpaid':
    145             self.flash(_("Payment ticket can't be re-send to CollegePAY."))
    146             self.redirect(self.url(self.context, '@@index'))
    147             return
    148         if self.context.__parent__.__parent__.expired \
    149             and self.context.__parent__.__parent__.strict_deadline:
    150             self.flash(_("Payment ticket can't be send to CollegePAY. "
    151                          "Application period has expired."))
    152             self.redirect(self.url(self.context, '@@index'))
    153             return
    154         self.applicant = self.context.__parent__
    155         self.amount_auth = 100 * self.context.amount_auth
     108        super(CustomInterswitchPageApplicant, self).update()
    156109        xmldict = {}
    157         self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
    158         tz = getUtility(IKofaUtils).tzinfo
    159         self.local_date_time = to_timezone(
    160             self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    161         self.site_redirect_url = self.url(self.context, 'request_webservice')
    162110        provider_amt = 400.0
    163111        xmldict['institution_acct'] = '00000000000'
     
    183131        return
    184132
    185 class InterswitchPaymentRequestWebservicePageStudent(
     133class CustomInterswitchPaymentRequestWebservicePageStudent(
    186134    InterswitchPaymentRequestWebservicePageStudent):
    187135    """ Request webservice view for the CollegePAY gateway
     
    192140    gateway_url = URL
    193141
    194 class InterswitchPaymentRequestWebservicePageApplicant(
     142class CustomInterswitchPaymentRequestWebservicePageApplicant(
    195143    InterswitchPaymentRequestWebservicePageApplicant):
    196144    """ Request webservice view for the CollegePAY gateway
Note: See TracChangeset for help on using the changeset viewer.