Ignore:
Timestamp:
13 May 2014, 06:25:18 (10 years ago)
Author:
Henrik Bettermann
Message:

Add base classes InterswitchPageApplicant? and InterswitchPageStudent? which can be used in custom packages.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch
Files:
3 added
1 edited

Legend:

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

    r11581 r11630  
    1717##
    1818import grok
    19 from waeup.kofa.browser.layout import UtilityView
     19from zope.component import getUtility
     20from waeup.kofa.interfaces import IKofaUtils
     21from waeup.kofa.utils.helpers import to_timezone
     22from waeup.kofa.browser.layout import UtilityView, KofaPage
    2023from waeup.kofa.browser.viewlets import ManageActionButton
    2124from waeup.kofa.students.browser import OnlinePaymentDisplayFormPage as OPDPStudent
     
    132135        self.redirect(self.url(self.context, '@@index'))
    133136        return
     137
     138class InterswitchPageStudent(KofaPage):
     139    """ View which sends a POST request to the Interswitch
     140    CollegePAY payment gateway.
     141    """
     142    grok.context(INigeriaOnlinePayment)
     143    grok.name('goto_interswitch')
     144    grok.template('student_goto_interswitch')
     145    grok.require('waeup.payStudent')
     146    label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
     147    submit_button = _('Submit')
     148
     149    def update(self):
     150        #if self.context.p_state != 'unpaid':
     151        if self.context.p_state == 'paid':
     152            self.flash(_("Payment ticket can't be re-send to CollegePAY."))
     153            self.redirect(self.url(self.context, '@@index'))
     154            return
     155
     156        student = self.student = self.context.student
     157        certificate = getattr(student['studycourse'],'certificate',None)
     158        if certificate is None:
     159            self.flash(_("Study course data are incomplete."))
     160            self.redirect(self.url(self.context, '@@index'))
     161            return
     162        self.amount_auth = 100 * self.context.amount_auth
     163        xmldict = {}
     164        if certificate is not None:
     165            xmldict['department'] = certificate.__parent__.__parent__.code
     166            xmldict['faculty'] = certificate.__parent__.__parent__.__parent__.code
     167        else:
     168            xmldict['department'] = None
     169            xmldict['faculty'] = None
     170        self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
     171        tz = getUtility(IKofaUtils).tzinfo
     172        self.local_date_time = to_timezone(
     173            self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
     174        self.site_redirect_url = self.url(self.context, 'request_webservice')
     175        return student, certificate, xmldict
     176
     177class InterswitchPageApplicant(KofaPage):
     178    """ View which sends a POST request to the Interswitch
     179    CollegePAY payment gateway.
     180    """
     181    grok.context(INigeriaApplicantOnlinePayment)
     182    grok.require('waeup.payApplicant')
     183    grok.template('applicant_goto_interswitch')
     184    grok.name('goto_interswitch')
     185    label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
     186    submit_button = _('Submit')
     187
     188    def update(self):
     189        if self.context.p_state != 'unpaid':
     190            self.flash(_("Payment ticket can't be re-send to CollegePAY."))
     191            self.redirect(self.url(self.context, '@@index'))
     192            return
     193        if self.context.__parent__.__parent__.expired \
     194            and self.context.__parent__.__parent__.strict_deadline:
     195            self.flash(_("Payment ticket can't be send to CollegePAY. "
     196                         "Application period has expired."))
     197            self.redirect(self.url(self.context, '@@index'))
     198            return
     199        self.applicant = self.context.__parent__
     200        self.amount_auth = 100 * self.context.amount_auth
     201        self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
     202        tz = getUtility(IKofaUtils).tzinfo
     203        self.local_date_time = to_timezone(
     204            self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
     205        self.site_redirect_url = self.url(self.context, 'request_webservice')
     206        return
Note: See TracChangeset for help on using the changeset viewer.