Changeset 11633


Ignore:
Timestamp:
13 May 2014, 07:53:40 (11 years ago)
Author:
Henrik Bettermann
Message:

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

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

Legend:

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

    r11611 r11633  
    441.2dev (unreleased)
    55===================
     6
     7* Use base classes InterswitchPageApplicant and InterswitchPageStudent from
     8  kofacustom.nigeria.
    69
    710* Viewlets for left thumb fingerprint minutiae file uploads added.
  • main/waeup.uniben/trunk/src/waeup/uniben/interswitch/browser.py

    r11478 r11633  
    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.uniben.students.interfaces import ICustomStudentOnlinePayment
    2926from waeup.uniben.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
     
    165134        return
    166135
    167 class InterswitchPageApplicant(KofaPage):
     136class CustomInterswitchPageApplicant(InterswitchPageApplicant):
    168137    """ View which sends a POST request to the Interswitch
    169138    CollegePAY payment gateway.
    170139    """
    171140    grok.context(ICustomApplicantOnlinePayment)
    172     grok.require('waeup.payApplicant')
    173     grok.template('applicant_goto_interswitch')
    174     grok.name('goto_interswitch')
    175     label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
    176     submit_button = _('Submit')
    177141    action = POST_ACTION
    178142    site_name = SITE_NAME
     
    182146
    183147    def update(self):
    184         if self.context.p_state != 'unpaid':
    185             self.flash(_("Payment ticket can't be re-send to CollegePAY."))
    186             self.redirect(self.url(self.context, '@@index'))
    187             return
    188         if self.context.__parent__.__parent__.expired \
    189             and self.context.__parent__.__parent__.strict_deadline:
    190             self.flash(_("Payment ticket can't be send to CollegePAY. "
    191                          "Application period has expired."))
    192             self.redirect(self.url(self.context, '@@index'))
    193             return
    194         self.applicant = self.context.__parent__
    195         self.amount_auth = 100 * self.context.amount_auth
     148        super(CustomInterswitchPageApplicant, self).update()
    196149        xmldict = {}
    197         self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
    198         tz = getUtility(IKofaUtils).tzinfo
    199         self.local_date_time = to_timezone(
    200             self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    201         self.site_redirect_url = self.url(self.context, 'request_webservice')
    202150        provider_amt = 400.0
    203151        if self.applicant.applicant_id.startswith('pg'):
     
    233181        return
    234182
    235 class InterswitchPaymentRequestWebservicePageStudent(
     183class CustomInterswitchPaymentRequestWebservicePageStudent(
    236184    InterswitchPaymentRequestWebservicePageStudent):
    237185    """ Request webservice view for the CollegePAY gateway
     
    242190    gateway_url = URL
    243191
    244 class InterswitchPaymentRequestWebservicePageApplicant(
     192class CustomInterswitchPaymentRequestWebservicePageApplicant(
    245193    InterswitchPaymentRequestWebservicePageApplicant):
    246194    """ Request webservice view for the CollegePAY gateway
  • main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py

    r11478 r11633  
    361361        self.assertTrue(
    362362            'zope.mgr - '
    363             'waeup.uniben.interswitch.browser.InterswitchPaymentRequestWebservicePageStudent - '
     363            'waeup.uniben.interswitch.browser.CustomInterswitchPaymentRequestWebservicePageStudent - '
    364364            'B1000000 - successful schoolfee payment: p3547789850240\n'
    365365            in logcontent)
Note: See TracChangeset for help on using the changeset viewer.