Changeset 15131


Ignore:
Timestamp:
7 Sep 2018, 09:01:25 (6 years ago)
Author:
Henrik Bettermann
Message:

Hide workflow state and history if admission checking fee has not been paid.

Location:
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/applicant.py

    r15123 r15131  
    2121from waeup.kofa.applicants.applicant import ApplicantFactory
    2222from waeup.kofa.utils.helpers import attrs_to_fields
     23from waeup.kofa.interfaces import IObjectHistory
     24from waeup.kofa.applicants.workflow import (
     25    application_states_dict, ADMITTED, NOT_ADMITTED, CREATED)
    2326from kofacustom.nigeria.applicants.applicant import NigeriaApplicant
    2427from kofacustom.edopoly.applicants.interfaces import(
     
    4750        return False
    4851
     52    @property
     53    def history(self):
     54        # We do not provide a history
     55        if self.state in (ADMITTED, NOT_ADMITTED, CREATED) \
     56            and not self.admchecking_fee_paid():
     57            return
     58        history = IObjectHistory(self)
     59        return history
     60
     61    @property
     62    def translated_state(self):
     63        if self.state in (ADMITTED, NOT_ADMITTED, CREATED) \
     64            and not self.admchecking_fee_paid():
     65            return
     66        try:
     67            state = application_states_dict[self.state]
     68        except LookupError:  # in unit tests
     69            return
     70        return state
     71
    4972# Set all attributes of CustomApplicant required in ICustomApplicant as field
    5073# properties. Doing this, we do not have to set initial attributes
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/browser.py

    r15124 r15131  
    4242    PG_OMIT_EDIT_FIELDS,
    4343    )
    44 from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED
     44from waeup.kofa.applicants.workflow import (
     45    ADMITTED, PAID, STARTED, NOT_ADMITTED, CREATED)
    4546from kofacustom.edopoly.applicants.interfaces import (
    4647    ICustomUGApplicantEdit, ICustomUGApplicant,
     
    107108    @property
    108109    def admission_checking_info(self):
    109         if self.context.state == ADMITTED and \
     110        if self.context.state in (ADMITTED, NOT_ADMITTED, CREATED) and \
    110111            not self.context.admchecking_fee_paid():
    111112            return _('You must pay the admission checking fee '
     
    116117        state = IWorkflowState(self.context).getState()
    117118        actions = []
    118         if state == ADMITTED and not self.context.admchecking_fee_paid():
     119        if state in (ADMITTED, NOT_ADMITTED, CREATED) \
     120            and not self.context.admchecking_fee_paid():
    119121            actions = [_('Add admission checking payment ticket')]
    120122        return actions
     
    186188    def update(self):
    187189        super(CustomExportPDFPageApplicationSlip, self).update()
    188         if self.context.state == ADMITTED and \
     190        if self.context.state in (ADMITTED, NOT_ADMITTED, CREATED) and \
    189191            not self.context.admchecking_fee_paid():
    190192            self.flash(
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/browser_templates/applicantdisplaypage.pt

    r15123 r15131  
    1 <h2 i18n:domain="waeup.kofa">
     1<h2 i18n:domain="waeup.kofa" tal:condition="context/translated_state">
    22  ...
    33  <span tal:replace="context/translated_state">APPLICATIONSTATE
     
    99</h2>
    1010
    11 <div class="workflow">
     11<div class="workflow" tal:condition="context/history">
    1212  <div tal:repeat="msg context/history/messages">
    1313    <span tal:replace="msg">MESSAGE</span><br />
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/payment.py

    r15000 r15131  
    2525from waeup.kofa.utils.helpers import attrs_to_fields
    2626from kofacustom.edopoly.applicants.interfaces import ICustomApplicantOnlinePayment
     27from kofacustom.edopoly.interfaces import MessageFactory as _
    2728
    2829class CustomApplicantOnlinePayment(ApplicantOnlinePayment):
     
    4041        super(CustomApplicantOnlinePayment, self).__init__()
    4142        return
     43
     44    def doAfterApplicantPaymentApproval(self):
     45        """Process applicant after payment was approved.
     46        """
     47        if not (self.__parent__.special and self.__parent__.state == PAID) \
     48            and self.p_category != 'admission_checking':
     49            wf_info = IWorkflowInfo(self.__parent__)
     50            try:
     51                wf_info.fireTransition('approve')
     52            except InvalidTransitionError:
     53                msg = log = 'Error: %s' % sys.exc_info()[1]
     54                return 'danger', msg, log
     55        log = 'approved: %s' % self.p_id
     56        msg = _('Payment approved')
     57        flashtype = 'success'
     58        return flashtype, msg, log
     59
     60    def doAfterApplicantPayment(self):
     61        """Process applicant after payment was made.
     62        """
     63        if not (self.__parent__.special and self.__parent__.state == PAID) \
     64            and self.p_category != 'admission_checking':
     65            wf_info = IWorkflowInfo(self.__parent__)
     66            try:
     67                wf_info.fireTransition('pay')
     68            except InvalidTransitionError:
     69                msg = log = 'Error: %s' % sys.exc_info()[1]
     70                return 'danger', msg, log
     71        log = 'successful payment: %s' % self.p_id
     72        msg = _('Successful payment')
     73        flashtype = 'success'
     74        return flashtype, msg, log
    4275
    4376CustomApplicantOnlinePayment = attrs_to_fields(
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/tests/test_browser.py

    r15123 r15131  
    7474            'Please pay admission checking fee before trying to download'
    7575            in self.browser.contents)
     76        # History and state is also missing
     77        self.assertFalse('...' in self.browser.contents)
     78        self.assertFalse('Application initialized' in self.browser.contents)
    7679        # Pay admission checking fee.
    7780        self.browser.getControl("Add admission checking").click()
     
    8487        self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
    8588        self.assertTrue('<span>55</span>' in self.browser.contents)
     89        # History and state are visible
     90        self.assertTrue('...' in self.browser.contents)
     91        self.assertTrue('Application initialized' in self.browser.contents)
    8692        # Application slip can be downloaded again.
    8793        self.browser.getLink("Download application slip").click()
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/viewlets.py

    r15123 r15131  
    2020from waeup.kofa.browser.viewlets import ManageActionButton
    2121from waeup.kofa.applicants.viewlets import PDFActionButton
     22from waeup.kofa.applicants.workflow import (
     23    INITIALIZED, ADMITTED, PAID, STARTED, NOT_ADMITTED, CREATED)
    2224from kofacustom.edopoly.applicants.interfaces import ICustomApplicant
    2325from kofacustom.edopoly.interfaces import MessageFactory as _
     
    2931        """Get a URL to the target...
    3032        """
    31         if self.context.state in ('initialized', 'started', 'paid') \
     33        if self.context.state in (INITIALIZED, STARTED, PAID) \
    3234            or self.context.special:
    3335            return
    34         if self.context.state == 'admitted' and \
     36        if self.context.state in (ADMITTED, NOT_ADMITTED, CREATED) and \
    3537            not self.context.admchecking_fee_paid():
    3638            return
Note: See TracChangeset for help on using the changeset viewer.