Changeset 14804


Ignore:
Timestamp:
18 Aug 2017, 06:43:53 (7 years ago)
Author:
Henrik Bettermann
Message:

Allow ApplicantOnlinePaymentProcessor to import records without p_id column in create mode.

Location:
main/waeup.kofa/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r14734 r14804  
    441.6.dev0 (unreleased)
    55=======================
     6
     7* Allow `ApplicantOnlinePaymentProcessor` to import records without
     8  `p_id` column in create mode.
    69
    710* Add `waeup.showStudents` permission to `ExportManager` role.
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/batching.py

    r13873 r14804  
    360360    factory_name = 'waeup.ApplicantOnlinePayment'
    361361
    362     location_fields = ['applicant_id', 'p_id']
     362    location_fields = ['applicant_id',]
    363363
    364364    @property
    365365    def available_fields(self):
    366366        af = sorted(list(set(
    367             self.location_fields + getFields(self.iface).keys())))
     367            self.location_fields + getFields(self.iface).keys())) +
     368            ['p_id',])
    368369        af.remove('display_item')
    369370        return af
     371
     372    def checkHeaders(self, headerfields, mode='ignore'):
     373        super(ApplicantOnlinePaymentProcessor, self).checkHeaders(headerfields)
     374        if mode in ('update', 'remove') and not 'p_id' in headerfields:
     375            raise FatalCSVError(
     376                "Need p_id for import in update and remove modes!")
     377        return True
    370378
    371379    def parentsExist(self, row, site):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/sample_payment_data.csv

    r13872 r14804  
    11applicant_id,p_state,p_category,p_id,p_session,r_amount_approved,amount_auth,creation_date,type
     2dp2011_1234,failed,application,,2016,19500.1,10500.1,2011-11-25 20:16:33.757 WAT,online
    23dp2011_1234,paid,application,p1266236341955,2015,19500.1,19500.1,2010-11-25 20:16:33.757 WAT,online
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py

    r13873 r14804  
    530530        num, num_warns, fin_file, fail_file = self.processor.doImport(
    531531            self.csv_file, PAYMENT_HEADER_FIELDS,'create')
    532         self.assertEqual(num_warns,1)
     532        self.assertEqual(num_warns,2)
    533533        fail_file = open(fail_file).read()
    534534        self.assertTrue('Payment has already been made' in fail_file)
     
    538538        num, num_warns, fin_file, fail_file = self.processor.doImport(
    539539            self.csv_file, PAYMENT_HEADER_FIELDS,'create')
     540        # Both records can be imported now.
    540541        self.assertEqual(num_warns,0)
     542        # One with imported and known p_id ...
    541543        payment = self.processor.getEntry(dict(applicant_id='dp2011_1234',
    542544            p_id='p1266236341955'), self.app)
     
    548550        self.assertEqual(cdate, '2010-11-25 21:16:33')
    549551        self.assertEqual(str(payment.creation_date.tzinfo),'UTC')
     552        # ... the other one with generated p_id.
     553        p_id_failed = self.applicant2.keys()[1]
     554        payment_failed = self.processor.getEntry(dict(applicant_id='dp2011_1234',
     555            p_id=p_id_failed), self.app)
     556        self.assertEqual(payment_failed.p_state, 'failed')
     557        self.assertEqual(payment_failed.amount_auth, 10500.1)
    550558        shutil.rmtree(os.path.dirname(fin_file))
    551559        logcontent = open(self.logfile).read()
     
    553561        self.assertTrue(
    554562            'INFO - system - ApplicantOnlinePayment Processor - dp2011_1234 - '
    555             'previous update cancelled'
    556             in logcontent)
     563            'previous update cancelled' in logcontent)
    557564        self.assertTrue(
    558565            'INFO - system - ApplicantOnlinePayment Processor - '
     
    560567            'creation_date=2010-11-25 21:16:33.757000+00:00, '
    561568            'r_amount_approved=19500.1, p_category=application, '
    562             'amount_auth=19500.1, p_session=2015, p_state=paid'
    563             in logcontent)
     569            'amount_auth=19500.1, p_session=2015, p_state=paid' in logcontent)
     570        self.assertTrue(
     571            'INFO - system - ApplicantOnlinePayment Processor - '
     572            'sample_payment_data - dp2011_1234 - updated: p_id=%s, '
     573            'creation_date=2011-11-25 21:16:33.757000+00:00, '
     574            'r_amount_approved=19500.1, p_category=application, '
     575            'amount_auth=10500.1, p_session=2016, p_state=failed'
     576            % p_id_failed in logcontent)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r14654 r14804  
    748748
    749749    The `checkConversion` method checks the format of the payment identifier.
    750     In create mode it does also ensures that same p_id does not exist
     750    In create mode it does also ensures that same `p_id` does not exist
    751751    elsewhere. It must be portal-wide unique.
    752752
Note: See TracChangeset for help on using the changeset viewer.