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

Define method which initiates update method.

File:
1 edited

Legend:

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

    r11639 r11642  
    2222from waeup.kofa.browser.layout import UtilityView, KofaPage
    2323from waeup.kofa.browser.viewlets import ManageActionButton
     24from waeup.kofa.students.interfaces import IStudentsUtils
    2425from waeup.kofa.students.browser import OnlinePaymentDisplayFormPage as OPDPStudent
    2526from waeup.kofa.applicants.browser import OnlinePaymentDisplayFormPage as OPDPApplicant
     
    116117    def update(self):
    117118        if self.context.p_state == 'paid':
    118             self.flash(_('This ticket has already been paid.'), type='warning')
     119            self.flash(_('This ticket has already been paid.'), type='danger')
    119120            return
    120121        applicant = self.context.__parent__
     
    154155    xml_data = None
    155156
    156     def update(self):
    157         #if self.context.p_state != 'unpaid':
    158         if self.context.p_state == 'paid':
    159             self.flash(_("Payment ticket can't be re-send to CollegePAY."))
    160             self.redirect(self.url(self.context, '@@index'))
    161             return
    162 
    163         student = self.student = self.context.student
     157    def init_update(self):
     158        if self.context.p_state == 'paid':
     159            return _("Payment ticket can't be re-sent to CollegePAY.")
     160        student = self.context.student
    164161        certificate = getattr(student['studycourse'],'certificate',None)
    165162        if certificate is None:
    166             self.flash(_("Study course data are incomplete."))
    167             self.redirect(self.url(self.context, '@@index'))
    168             return
     163            return _("Study course data are incomplete.")
    169164        kofa_utils = getUtility(IKofaUtils)
     165        student_utils = getUtility(IStudentsUtils)
     166        if student_utils.samePaymentMade(student, self.context.p_category,
     167            self.context.p_item, self.context.p_session):
     168            return _("This type of payment has already been made.")
    170169        self.amount_auth = 100 * self.context.amount_auth
    171170        xmldict = {}
     
    181180            self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    182181        self.site_redirect_url = self.url(self.context, 'request_webservice')
    183         return student, certificate, xmldict
     182        self.student = student
     183        self.xmldict = xmldict
     184        return
     185
     186    def update(self):
     187        error = self.init_update()
     188        if error:
     189            self.flash(error, type='danger')
     190            self.redirect(self.url(self.context, '@@index'))
     191        return
    184192
    185193class InterswitchPageApplicant(KofaPage):
     
    201209    xml_data = None
    202210
    203     def update(self):
     211    def init_update(self):
    204212        if self.context.p_state != 'unpaid':
    205             self.flash(_("Payment ticket can't be re-send to CollegePAY."))
    206             self.redirect(self.url(self.context, '@@index'))
    207             return
     213            return _("Payment ticket can't be re-sent to CollegePAY.")
    208214        if self.context.__parent__.__parent__.expired \
    209215            and self.context.__parent__.__parent__.strict_deadline:
    210             self.flash(_("Payment ticket can't be send to CollegePAY. "
    211                          "Application period has expired."))
    212             self.redirect(self.url(self.context, '@@index'))
    213             return
     216            return _("Payment ticket can't be send to CollegePAY. "
     217                     "Application period has expired.")
    214218        self.applicant = self.context.__parent__
    215219        self.amount_auth = 100 * self.context.amount_auth
     
    220224        self.site_redirect_url = self.url(self.context, 'request_webservice')
    221225        return
     226
     227    def update(self):
     228        error = self.init_update()
     229        if error:
     230            self.flash(error, type='danger')
     231            self.redirect(self.url(self.context, '@@index'))
     232        return
Note: See TracChangeset for help on using the changeset viewer.