Ignore:
Timestamp:
22 Jun 2016, 04:39:50 (8 years ago)
Author:
Henrik Bettermann
Message:

Make provision against storing other objects than applicant payments in applicant containers.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
7 edited

Legend:

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

    r13224 r13968  
    4141    IApplicant, IApplicantEdit, ISpecialApplicant)
    4242from waeup.kofa.applicants.workflow import application_states_dict
     43from waeup.kofa.applicants.payment import ApplicantOnlinePayment
    4344
    4445def search(query=None, searchtype=None, view=None):
     
    7172        self.applicant_id = None
    7273        return
     74
     75    @property
     76    def payments(self):
     77        payments = [value for value in self.values()
     78            if isinstance(value, ApplicantOnlinePayment)]
     79        return payments
    7380
    7481    def writeLogMessage(self, view, message):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantdisplaypage.pt

    r13886 r13968  
    5454    </thead>
    5555    <tbody>
    56       <tr tal:repeat="value context/values">
     56      <tr tal:repeat="value context/payments">
    5757        <td> <a tal:attributes="href python:view.url(value)">
    5858        <span tal:content="value/p_id">PID</span></a></td>
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicanteditpage.pt

    r13886 r13968  
    106106      </thead>
    107107      <tbody>
    108         <tr tal:repeat="cl context/values">
     108        <tr tal:repeat="cl context/payments">
    109109           <td>
    110110            <input type="checkbox"
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/export.py

    r13952 r13968  
    201201        payments = []
    202202        for applicant in used:
    203             for payment in applicant.values():
     203            for payment in applicant.payments:
    204204                if payment.p_state == 'paid':
    205205                    payments.append(payment)
     
    215215        payments = []
    216216        for applicant in used:
    217             for payment in applicant.values():
     217            for payment in applicant.payments:
    218218                if payment.p_state == 'paid':
    219219                    payments.append(payment)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicant.py

    r13216 r13968  
    3434    )
    3535from waeup.kofa.applicants.interfaces import IApplicant
     36from waeup.kofa.applicants.payment import ApplicantOnlinePayment
    3637from waeup.kofa.testing import FunctionalTestCase, FunctionalLayer
    3738
     
    205206        return
    206207
     208    def test_payments(self):
     209        payment = ApplicantOnlinePayment()
     210        no_payment = object()
     211        self.applicant['pid'] = payment
     212        self.applicant['nopid'] = no_payment
     213        self.assertEqual(len(self.applicant.values()),2)
     214        self.assertEqual(len(self.applicant.payments),1)
     215        self.assertEqual(self.applicant.payments[0],payment)
     216        return
     217
    207218class ApplicantFactoryTest(FunctionalTestCase):
    208219
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r13951 r13968  
    10791079        self.assertEqual(len(self.special_applicant.keys()), 1)
    10801080        # The applicant's workflow state is paid ...
    1081         self.special_applicant.values()[0].approveApplicantPayment()
     1081        self.special_applicant.payments[0].approveApplicantPayment()
    10821082        self.assertEqual(self.special_applicant.state, 'paid')
    10831083        self.browser.open(applicant_path + '/edit')
     
    10941094        self.assertEqual(len(self.special_applicant.keys()), 2)
    10951095        # Second payment can also be approved wthout error message
    1096         flashtype, msg, log = self.special_applicant.values()[1].approveApplicantPayment()
     1096        flashtype, msg, log = self.special_applicant.payments[1].approveApplicantPayment()
    10971097        self.assertEqual(flashtype, 'success')
    10981098        self.assertEqual(msg, 'Payment approved')
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py

    r13952 r13968  
    283283        applicant = self.setup_applicant(self.applicant)
    284284        exporter = ApplicantPaymentExporter()
    285         exporter.export(applicant.values(), self.outfile)
     285        exporter.export(applicant.payments, self.outfile)
    286286        result = open(self.outfile, 'rb').read()
    287287        cdate = str('%s#' % self.applicant['p120'].creation_date)
Note: See TracChangeset for help on using the changeset viewer.