Changeset 8336


Ignore:
Timestamp:
4 May 2012, 05:14:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Applicants in state created are blocked. They can't be edited by import.

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

Legend:

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

    r8334 r8336  
    3232from waeup.kofa.applicants.interfaces import (
    3333    IApplicantsContainer, IApplicant, IApplicantUpdateByRegNo)
    34 from waeup.kofa.applicants.workflow import  IMPORTABLE_STATES
     34from waeup.kofa.applicants.workflow import  IMPORTABLE_STATES, CREATED
    3535
    3636class ApplicantsContainerProcessor(BatchProcessor):
     
    307307                conv_dict['application_number'] = IGNORE_MARKER
    308308        return errs, inv_errs, conv_dict
     309
     310    def checkUpdateRequirements(self, obj, row, site):
     311        """Checks requirements the object must fulfill when being updated.
     312
     313        This method is not used in case of deleting or adding objects.
     314
     315        Returns error messages as strings in case of requirement
     316        problems.
     317        """
     318        if obj.state == CREATED:
     319            return 'Applicant is blocked.'
     320        return None
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/sample_applicant_data.csv

    r8291 r8336  
    332345,dp2011,1002,Aaren,Finau,1990-01-03,xx@yy.zz,CERT1,m,Claus,
    44,dp2011,1003,Aaren,Berson,1990-01-04,xx@yy.zz,CERT1,m,Alfons,
     54567,dp2011,1004,Simon,Star,1990-01-05,xx@yy.zz,CERT1,m,Uwe,
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/sample_applicant_data_update2.csv

    r8331 r8336  
    1 applicant_id,reg_number,firstname,middlename
    2 dp2011_1234,,Aaren,XXX
    3 ,6666,Alfons,XXX
    4 ,1003,Abraham,XXX
     1applicant_id,reg_number,firstname,middlename,state
     2dp2011_1234,,Aaren,XXX,
     3,6666,Alfons,XXX,
     4,1003,Abraham,XXX,
     5,1004,Vertan,,
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py

    r8335 r8336  
    2525import unittest
    2626import grok
     27from hurry.workflow.interfaces import IWorkflowState
    2728from zope.component.hooks import setSite, clearSite
    2829from zope.component import createObject
     
    3940from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    4041from waeup.kofa.interfaces import IBatchProcessor, IUserAccount
     42from waeup.kofa.applicants.workflow import CREATED
    4143
    4244
     
    285287        self.assertEqual(num_warns,0)
    286288        keys = self.app['applicants']['dp2011'].keys()
    287         assert len(keys) == 4
     289        assert len(keys) == 5
    288290        container = self.app['applicants']['dp2011']
    289291        assert  container.__implemented__.__name__ == (
     
    353355        self.assertEqual(container['2345'].reg_number, '6666')
    354356        logcontent = open(self.logfile).read()
    355 
    356357        # Logging message from updateEntry,
    357358        # reg_number is locator
     
    364365            'firstname=Alfons, applicant_id=dp2011_2345' in
    365366            logcontent)
    366 
    367367        shutil.rmtree(os.path.dirname(fin_file))
    368368
    369369        # Now we import another file which clears all middlename attributes
    370370        # and uses the new reg_number as locator. This test also checks
    371         # if the catalog has been informed about the reg_no change.
     371        # if the catalog has been informed about the reg_no change and if
     372        # applicants in state created are really blocked.
     373        IWorkflowState(container['4567']).setState(CREATED)
    372374        num, num_warns, fin_file, fail_file = self.processor.doImport(
    373375            self.csv_file_update2, APPLICANT_HEADER_FIELDS_UPDATE2, 'update')
    374         #content = open(fail_file).read()
    375         #print content
    376         self.assertEqual(num_warns,0)
     376        failcontent = open(fail_file).read()
     377        self.assertTrue('Applicant is blocked' in failcontent)
     378        self.assertEqual(num_warns,1)
     379        # Middlename is cleared.
    377380        assert container['1234'].middlename is None
     381        # Firstname of applicant in state created isn't changed.
     382        self.assertEqual(container['4567'].firstname, 'Simon')
    378383        shutil.rmtree(os.path.dirname(fin_file))
    379384
     
    386391        self.assertEqual(num_warns,0)
    387392        logcontent = open(self.logfile).read()
    388 
    389393        # Logging message from handle_applicant_transition_event
    390394        self.assertTrue(
    391395            'dp2011_1234 - Applicant record removed' in
    392396            logcontent)
    393 
    394         shutil.rmtree(os.path.dirname(fin_file))
     397        shutil.rmtree(os.path.dirname(fin_file))
Note: See TracChangeset for help on using the changeset viewer.