Ignore:
Timestamp:
10 Jul 2022, 08:40:43 (2 years ago)
Author:
Henrik Bettermann
Message:

Add BalancePaymentAddFormPage which can only be opened by managers.
No button is provided in base package.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r16976 r17016  
    4141    IApplicantOnlinePayment, IApplicantsUtils,
    4242    IApplicantRegisterUpdate, ISpecialApplicant,
    43     IApplicantRefereeReport
     43    IApplicantRefereeReport,
     44    IApplicantBalancePayment
    4445    )
    4546from waeup.kofa.utils.helpers import (html2dict,
     
    831832    def render(self):
    832833        return
     834       
     835class BalancePaymentAddFormPage(KofaAddFormPage):
     836    """ Page to add an online payment which can balance s previous session
     837    payment.
     838    """
     839    grok.context(IApplicant)
     840    grok.name('addbp')
     841    grok.template('balancepaymentaddform')
     842    grok.require('waeup.manageApplication')
     843    form_fields = grok.AutoFields(IApplicantBalancePayment)
     844    label = _('Add balance')
     845    #pnav = 4
     846
     847    @property
     848    def selectable_payment_options(self):
     849        options = getUtility(
     850            IKofaUtils).selectable_payment_options(self.context)
     851        return sorted(options.items(), key=lambda value: value[1])
     852
     853    @action(_('Create ticket'), style='primary')
     854    def createTicket(self, **data):
     855        p_category = data['p_category']
     856        p_option = data.get('p_option', None)
     857        balance_amount = data.get('balance_amount', None)
     858        applicants_utils = getUtility(IApplicantsUtils)
     859        error, payment = applicants_utils.setBalanceDetails(
     860            self.context, p_category, balance_amount)
     861        if error is not None:
     862            self.flash(error, type="danger")
     863            return
     864        if p_option:
     865            payment.p_option = p_option
     866        self.context[payment.p_id] = payment
     867        self.flash(_('Payment ticket created.'))
     868        self.context.writeLogMessage(self,'added: %s' % payment.p_id)
     869        self.redirect(self.url(payment))
     870        return
     871
     872    @action(_('Cancel'), validator=NullValidator)
     873    def cancel(self, **data):
     874        self.redirect(self.url(self.context))
    833875
    834876
Note: See TracChangeset for help on using the changeset viewer.