Ignore:
Timestamp:
13 Jul 2021, 16:25:31 (3 years ago)
Author:
Henrik Bettermann
Message:

Adjust to changes in base package.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/applicants
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/browser.py

    r16003 r16548  
    407407
    408408    def display_fileupload(self, filename):
    409         if filename[1] == 'stateresult.pdf':
     409        if filename[1] == 'stateresult':
    410410            if self.target in ('trans', 'cert'):
    411411                return True
    412         if filename[1] == 'verificationdoc.pdf':
     412        if filename[1] == 'verificationdoc':
    413413            if self.target in ('ver', 'send'):
    414414                return True
     
    464464
    465465    def display_fileupload(self, filename):
    466         if filename[1] == 'stateresult.pdf':
     466        if filename[1] == 'stateresult':
    467467            if self.target in ('trans', 'cert'):
    468468                return True
    469         if filename[1] == 'verificationdoc.pdf':
     469        if filename[1] == 'verificationdoc':
    470470            if self.target in ('ver', 'send'):
    471471                return True
     
    486486                return _('Passport picture confirmation box not ticked.')
    487487        if self.target in ('trans', 'cert') and \
    488             not store.getFileByContext(self.context, attr=u'stateresult.pdf'):
     488            not store.getFileByContext(self.context, attr=u'stateresult'):
    489489            return _('No statement of result pdf file uploaded.')
    490490        if self.target in ('ver',) and \
    491             not store.getFileByContext(self.context, attr=u'verificationdoc.pdf'):
     491            not store.getFileByContext(self.context, attr=u'verificationdoc'):
    492492            return _('No pdf file uploaded.')
    493493        if self.target == 'fedex':
     
    785785    """Renders the pdf form extension for applicants.
    786786    """
    787     grok.name('stateresult.pdf')
     787    grok.name('stateresult')
    788788
    789789class VerificationDoc(AdditionalFile):
    790790    """Renders the pdf form extension for applicants.
    791791    """
    792     grok.name('verificationdoc.pdf')
     792    grok.name('verificationdoc')
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/browser_templates/applicanteditpage.pt

    r16135 r16548  
    5353              <p tal:condition="python:view.file_exists(filename[1])">
    5454                <a tal:attributes="href python:filename[1]"i18n:translate="">
    55                   Download pdf file
     55                  Download file
    5656                </a>
    5757              </p>
     
    6666              </div>
    6767              <span i18n:translate="">
    68                 PDF files only. Max. file size:
     68                PDF or JPG files only. Max. file size:
    6969              </span>
    7070              <span tal:replace="view/max_file_upload_size">10 KB</span>
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py

    r16240 r16548  
    3232from waeup.kofa.applicants.tests.test_browser import (
    3333    ApplicantsFullSetup, container_name_1, session_1)
     34
     35SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
    3436
    3537class CustomApplicantUITest(ApplicantsFullSetup):
     
    344346        self.browser.open(self.transapplicant_manage_path)
    345347        # Create a pseudo file with acceptable size
    346         pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
    347         pseudo_pdf = StringIO(pdf_content)
    348         ctrl = self.browser.getControl(name='stateresult.pdf')
     348        #pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
     349        #pseudo_pdf = StringIO(pdf_content)
     350        image = open(SAMPLE_IMAGE, 'rb')
     351        ctrl = self.browser.getControl(name='stateresult')
    349352        file_ctrl = ctrl.mech_control
    350         file_ctrl.add_file(pseudo_pdf, filename='myform.pdf')
     353        file_ctrl.add_file(image, filename='my_scan.jpg')
    351354        self.browser.getControl("Save").click() # submit form
    352355        # Even though the form could not be saved ...
    353356        self.assertTrue('Required input is missing' in self.browser.contents)
    354357        # ... the file has been successfully uploaded
    355         pdf_url = self.transapplicant_manage_path.replace('manage', 'stateresult.pdf')
    356         self.browser.open(pdf_url)
     358        image_url = self.transapplicant_manage_path.replace('manage', 'stateresult')
     359        self.browser.open(image_url)
    357360        self.assertEqual(
    358             self.browser.headers['content-type'], 'application/pdf')
    359         self.assertEqual(len(self.browser.contents), 307200)
     361            self.browser.headers['content-type'], 'image/jpeg')
     362        self.assertEqual(len(self.browser.contents), 2787)
    360363        # There is really a file stored for the applicant
    361364        storage = getUtility(IExtFileStore)
     
    365368        fd = storage.getFile(file_id)
    366369        file_len = len(fd.read())
    367         self.assertEqual(file_len, 307200)
     370        self.assertEqual(file_len, 2787)
    368371        # A file link is displayed on the edit view ...
    369372        self.browser.open(self.transapplicant_manage_path)
    370         self.assertTrue('<a href="stateresult.pdf">' in self.browser.contents)
     373        self.assertTrue('<a href="stateresult">' in self.browser.contents)
    371374        # ... and on the dislay view
    372375        self.browser.open(self.transapplicant_view_path)
    373         self.assertTrue('stateresult.pdf">Statement of Result</a>'
     376        self.assertTrue('stateresult">Statement of Result</a>'
    374377            in self.browser.contents)
    375378        # Adding file is properly logged
     
    416419        self.browser.open(self.verapplicant_manage_path)
    417420        # Create a pseudo file with acceptable size
    418         pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
    419         pseudo_pdf = StringIO(pdf_content)
    420         ctrl = self.browser.getControl(name='verificationdoc.pdf')
     421        #pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
     422        #pseudo_pdf = StringIO(pdf_content)
     423        image = open(SAMPLE_IMAGE, 'rb')
     424        ctrl = self.browser.getControl(name='verificationdoc')
    421425        file_ctrl = ctrl.mech_control
    422         file_ctrl.add_file(pseudo_pdf, filename='myform.pdf')
     426        file_ctrl.add_file(image, filename='my_scan.jpg')
    423427        self.browser.getControl("Save").click() # submit form
    424428        # Even though the form could not be saved ...
    425429        self.assertTrue('Required input is missing' in self.browser.contents)
    426430        # ... the file has been successfully uploaded
    427         pdf_url = self.verapplicant_manage_path.replace('manage', 'verificationdoc.pdf')
    428         self.browser.open(pdf_url)
     431        image_url = self.verapplicant_manage_path.replace('manage', 'verificationdoc')
     432        self.browser.open(image_url)
    429433        self.assertEqual(
    430             self.browser.headers['content-type'], 'application/pdf')
    431         self.assertEqual(len(self.browser.contents), 307200)
     434            self.browser.headers['content-type'], 'image/jpeg')
     435        self.assertEqual(len(self.browser.contents), 2787)
    432436        # There is really a file stored for the applicant
    433437        storage = getUtility(IExtFileStore)
     
    437441        fd = storage.getFile(file_id)
    438442        file_len = len(fd.read())
    439         self.assertEqual(file_len, 307200)
     443        self.assertEqual(file_len, 2787)
    440444        # A file link is displayed on the edit view ...
    441445        self.browser.open(self.verapplicant_manage_path)
    442         self.assertTrue('<a href="verificationdoc.pdf">' in self.browser.contents)
     446        self.assertTrue('<a href="verificationdoc">' in self.browser.contents)
    443447        # ... and on the dislay view
    444448        self.browser.open(self.verapplicant_view_path)
    445         self.assertTrue('verificationdoc.pdf">Result/Certificate Document</a>'
     449        self.assertTrue('verificationdoc">Result/Certificate Document</a>'
    446450            in self.browser.contents)
    447451        # Adding file is properly logged
     
    454458            % (self.verapplicant.applicant_id)
    455459            in logcontent)
    456         # When an applicant is removed, also the pdf files are gone.
     460        # When an applicant is removed, also the files are gone.
    457461        del self.app['applicants'][self.vercontainer.code][self.verapplicant.application_number]
    458462        fd = storage.getFile(file_id)
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/utils.py

    r16135 r16548  
    2828    """
    2929
    30     ADDITIONAL_FILES = (('Statement of Result','stateresult.pdf'),
    31                  ('Result/Certificate Document','verificationdoc.pdf'))
     30    ADDITIONAL_FILES = (('Statement of Result','stateresult'),
     31                 ('Result/Certificate Document','verificationdoc'))
    3232
    3333    APP_TYPES_DICT = {
Note: See TracChangeset for help on using the changeset viewer.