Changeset 11782


Ignore:
Timestamp:
29 Aug 2014, 05:31:07 (10 years ago)
Author:
Henrik Bettermann
Message:

Copy over some stuff from waeup.kofa needed for admission checking customization. See ticket #947.

Location:
main/waeup.uniben/trunk/src/waeup/uniben
Files:
4 edited

Legend:

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

    r11771 r11782  
    1919"""
    2020import grok
    21 from zope.component import getUtility
     21from zope.component import getUtility, createObject
    2222from zope.security import checkPermission
    2323from waeup.kofa.interfaces import IExtFileStore
    2424from waeup.kofa.applicants.browser import (
    2525    ApplicantRegistrationPage, ApplicantsContainerPage,
    26     ApplicationFeePaymentAddPage)
     26    ApplicationFeePaymentAddPage,
     27    OnlinePaymentApprovePage)
     28from waeup.kofa.applicants.interfaces import (
     29    ISpecialApplicant, IApplicantsUtils)
    2730from kofacustom.nigeria.applicants.browser import (
    2831    NigeriaApplicantDisplayFormPage,
    2932    NigeriaApplicantManageFormPage,
    3033    NigeriaPDFApplicationSlip)
     34from waeup.uniben.applicants.interfaces import (
     35    ICustomApplicant)
    3136
    3237from waeup.uniben.interfaces import MessageFactory as _
     
    106111        return self.target.startswith('pude') \
    107112               and self.context.state in ('paid', 'submitted')
     113
     114    # customizations for admission checking payments
     115    @property
     116    def form_fields(self):
     117        if self.context.special:
     118            form_fields = grok.AutoFields(ISpecialApplicant).omit('locked')
     119        else:
     120            form_fields = grok.AutoFields(ICustomApplicant).omit(
     121                'locked', 'course_admitted', 'password', 'suspended')
     122        return form_fields
    108123
    109124class CustomNigeriaPDFApplicationSlip(NigeriaPDFApplicationSlip):
     
    129144        store = getUtility(IExtFileStore)
    130145        if not store.getFileByContext(self.context, attr=u'passport.jpg'):
    131             return _('Upload your 1"x1" Red  background passport photo before making payment.')
     146            return _('Upload your 1"x1" Red background passport photo before making payment.')
    132147        return ''
    133148
    134 
    135 class ApplicantManageFormPage(NigeriaApplicantManageFormPage):
     149    # customizations for admission checking payments
     150    def update(self):
     151        # Additional requirements in custom packages.
     152        if self.custom_requirements:
     153            self.flash(
     154                self.custom_requirements,
     155                type='danger')
     156            self.redirect(self.url(self.context))
     157            return
     158        if not self.context.special:
     159            for key in self.context.keys():
     160                ticket = self.context[key]
     161                if ticket.p_state == 'paid':
     162                      self.flash(
     163                          _('This type of payment has already been made.'),
     164                          type='warning')
     165                      self.redirect(self.url(self.context))
     166                      return
     167        applicants_utils = getUtility(IApplicantsUtils)
     168        container = self.context.__parent__
     169        payment = createObject(self.factory)
     170        failure = applicants_utils.setPaymentDetails(
     171            container, payment, self.context)
     172        if failure is not None:
     173            self.flash(failure[0], type='danger')
     174            self.redirect(self.url(self.context))
     175            return
     176        self.context[payment.p_id] = payment
     177        self.flash(_('Payment ticket created.'))
     178        self.redirect(self.url(payment))
     179        return
     180
     181
     182class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
    136183
    137184    @property
     
    139186        if not checkPermission('waeup.uploadPassportPictures', self.context):
    140187            return _('You are not entitled to upload passport pictures.')
     188
     189class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage):
     190    """ Approval view
     191    """
     192
     193    # customizations for admission checking payments
     194    def update(self):
     195        flashtype, msg, log = self.context.approveApplicantPayment()
     196        if log is not None:
     197            applicant = self.context.__parent__
     198            # Add log message to applicants.log
     199            applicant.writeLogMessage(self, log)
     200            # Add log message to payments.log
     201            self.context.logger.info(
     202                '%s,%s,%s,%s,%s,,,,,,' % (
     203                applicant.applicant_id,
     204                self.context.p_id, self.context.p_category,
     205                self.context.amount_auth, self.context.r_code))
     206        self.flash(msg, type=flashtype)
     207        return
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/utils.py

    r11434 r11782  
    1919"""
    2020
     21from time import time
     22import grok
    2123from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils
    2224from waeup.kofa.applicants.workflow import (INITIALIZED,
     
    2628
    2729
    28 class ApplicantsUtils(NigeriaApplicantsUtils):
     30class CustomApplicantsUtils(NigeriaApplicantsUtils):
    2931    """A collection of parameters and methods subject to customization.
    3032    """
     
    4951        }
    5052
     53    # customizations for admission checking payments
     54    def setPaymentDetails(self, container, payment, applicant):
     55        """Set the payment data of an applicant.
     56        """
     57        timestamp = ("%d" % int(time()*10000))[1:]
     58        session = str(container.year)
     59        try:
     60            session_config = grok.getSite()['configuration'][session]
     61        except KeyError:
     62            return _(u'Session configuration object is not available.'), None
     63        payment.p_id = "p%s" % timestamp
     64        payment.p_item = container.title
     65        payment.p_session = container.year
     66        payment.amount_auth = 0.0
     67        if applicant.special:
     68            if applicant.special_application:
     69                fee_name = applicant.special_application + '_fee'
     70                payment.amount_auth = getattr(session_config, fee_name, 0.0)
     71                payment.p_category = applicant.special_application
     72            return
     73        payment.p_category = 'application'
     74        container_fee = container.application_fee
     75        if container_fee:
     76            payment.amount_auth = container_fee
     77            return
     78        payment.amount_auth = session_config.application_fee
     79        if payment.amount_auth in (0.0, None):
     80            return _('Amount could not be determined.'), None
     81        return
     82
    5183
    5284    # Temporarily disabled
  • main/waeup.uniben/trunk/src/waeup/uniben/interfaces.py

    r10469 r11782  
    9494        )
    9595
     96    admchecking_fee = schema.Float(
     97        title = _(u'Admission Checking Fee'),
     98        default = 0.0,
     99        required = False,
     100        )
     101
    96102    def getSessionString():
    97103        """Returns the session string from the vocabulary.
  • main/waeup.uniben/trunk/src/waeup/uniben/utils/utils.py

    r11669 r11782  
    6363        'application': 'Application Fee',
    6464        'transcript': 'Transcript Fee',
     65        'admission_checking': 'Admission Checking Fee',
    6566        }
    6667
Note: See TracChangeset for help on using the changeset viewer.