Changeset 12162 for main/waeup.ikoba


Ignore:
Timestamp:
7 Dec 2014, 15:13:26 (10 years ago)
Author:
Henrik Bettermann
Message:

Set md5 attributes when verifying a document.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py

    r12161 r12162  
    126126        """Set md5 checksum attribute for all files connected to this document.
    127127        """
    128         for file in self.connected_files:
    129             attrname = '%s_md5' % file[0]
    130             checksum = md5(file[1].read()).hexdigest()
    131             setattr(self, attrname, checksum)
     128        connected_files = self.connected_files
     129        if connected_files:
     130            for file in self.connected_files:
     131                attrname = '%s_md5' % file[0]
     132                checksum = md5(file[1].read()).hexdigest()
     133                setattr(self, attrname, checksum)
    132134        return
    133135
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12161 r12162  
    975975        self.assertTrue(
    976976            'Uploaded file is too big' in self.browser.contents)
    977         # we do not rely on filename extensions given by uploaders
     977        # We do not rely on filename extensions given by uploaders
    978978        image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
    979979        ctrl = self.browser.getControl(name='samplescanmanageupload')
    980980        file_ctrl = ctrl.mech_control
    981         # tell uploaded file is bmp
     981        # Tell uploaded file is bmp
    982982        file_ctrl.add_file(image, filename='my_sample_scan.bmp')
    983983        self.browser.getControl(
     
    999999        self.assertTrue('Only the following extensions are allowed'
    10001000            in self.browser.contents)
     1001
     1002    def test_verify_document(self):
     1003        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1004        self.browser.open(self.customer_path + '/documents/d101/manage')
     1005        image = open(SAMPLE_IMAGE, 'rb')
     1006        ctrl = self.browser.getControl(name='samplescanmanageupload')
     1007        file_ctrl = ctrl.mech_control
     1008        file_ctrl.add_file(image, filename='my_sample_scan.jpg')
     1009        self.browser.getControl(
     1010            name='upload_samplescanmanageupload').click()
     1011        IWorkflowState(self.document).setState(SUBMITTED)
     1012        # Only after verifying the document, sample_md5 is set
     1013        self.assertEqual(
     1014            getattr(self.document, 'sample_md5', None), None)
     1015        self.browser.open(self.documents_path + '/d101/trigtrans')
     1016        self.browser.getControl(name="transition").value = ['verify']
     1017        self.browser.getControl("Save").click()
     1018        self.assertEqual(
     1019            getattr(self.document, 'sample_md5', None),
     1020                    '1d1ab893e87c240afb2104d61ddfe180')
    10011021
    10021022    def test_manage_upload_pdf_file(self):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/workflow.py

    r12089 r12162  
    129129    last_transition_date when transition happened.
    130130    """
     131    if event.transition.transition_id == 'verify':
     132        obj.setMD5()
    131133    msg = event.transition.user_data['msg']
    132134    history = IObjectHistory(obj)
Note: See TracChangeset for help on using the changeset viewer.