Changeset 8667


Ignore:
Timestamp:
11 Jun 2012, 05:24:10 (12 years ago)
Author:
Henrik Bettermann
Message:

We need to customize the attributes to be copied. Therefore it's easier to define these attributes in a list.

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

Legend:

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

    r8637 r8667  
    5454    grok.provides(IApplicant)
    5555
     56    create_names = [
     57        'firstname', 'lastname',
     58        'sex', 'date_of_birth',
     59        'email', 'phone'
     60        ]
     61
    5662    def __init__(self):
    5763        super(Applicant, self).__init__()
     
    113119        # Add student object
    114120        try:
    115             student.firstname = self.firstname
    116             student.lastname = self.lastname
    117             student.sex = self.sex
    118             student.date_of_birth = self.date_of_birth
    119             student.email = self.email
    120             student.phone = self.phone
     121            for name in self.create_names:
     122                setattr(student, name, getattr(self, name, None))
    121123        except RequiredMissing, err:
    122124            return False, _('RequiredMissing: %s' % err)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py

    r8637 r8667  
    7878        # Student is in state admitted
    7979        self.assertEqual(student.state, 'admitted')
     80        # Attributes properly set?
     81        self.assertEqual(student.email, 'xx@yy.zz')
     82        self.assertEqual(student.firstname, 'John')
     83        self.assertEqual(student.lastname, 'Tester')
    8084        # Check if passport image has been copied
    8185        storage = getUtility(IExtFileStore)
Note: See TracChangeset for help on using the changeset viewer.