Ignore:
Timestamp:
22 Apr 2013, 08:58:12 (11 years ago)
Author:
Henrik Bettermann
Message:

In the beginning the attr parameter was not taken into account for
Applicant context as the single passport image was the
only file we stored for applicants. Meanwhile FUTMinna requires
uploads of other documents too. Now we store passport image
files without attribute but all other documents with.

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

    r9544 r10089  
    278278        as parent name.
    279279
    280         The `attr` parameter is not taken into account for
    281         :class:`Applicant` context as the single passport image is the
    282         only file we store for applicants.
     280        In the beginning the `attr` parameter was not taken into account for
     281        :class:`Applicant` context as the single passport image was the
     282        only file we store for applicants. Meanwhile FUTMinna requires
     283        uploads of other documents too. Now we store passport image
     284        files without attribute but all other documents with.
    283285
    284286        """
     
    286288            getattr(self.context, '__parent__', None),
    287289            '__name__', '_default')
    288         marked_filename = '__%s__%s/%s.jpg' % (
    289             APPLICANT_IMAGE_STORE_NAME,
    290             parent_name, self.context.applicant_id)
     290        if attr is None or attr == 'passport.jpg':
     291            marked_filename = '__%s__%s/%s.jpg' % (
     292                APPLICANT_IMAGE_STORE_NAME,
     293                parent_name, self.context.applicant_id)
     294        else:
     295            basename, ext = os.path.splitext(attr)
     296            marked_filename = '__%s__%s/%s_%s%s' % (
     297                APPLICANT_IMAGE_STORE_NAME,
     298                parent_name, self.context.applicant_id, basename, ext)
    291299        return marked_filename
    292300
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicant.py

    r9287 r10089  
    144144        return
    145145
     146    def test_name_chooser_applicant_nonpassport_w_container(self):
     147        fake_container = grok.Container()
     148        fake_container.__name__ = 'folder'
     149        fake_container.code = 'folder'
     150        appl = Applicant()
     151        appl.applicant_id = u'folder_123456'
     152        appl.__parent__ = fake_container
     153        chooser = IFileStoreNameChooser(appl)
     154        result = chooser.chooseName(attr='any.pdf')
     155        self.assertEqual(
     156            result, '__img-applicant__folder/%s_any.pdf' % appl.applicant_id)
     157        return
     158
    146159    def test_name_chooser_check_name(self):
    147160        # we can check file ids for applicants
Note: See TracChangeset for help on using the changeset viewer.