Ignore:
Timestamp:
4 Jun 2024, 07:54:30 (7 months ago)
Author:
Henrik Bettermann
Message:

Limit the file name length to 65 characters.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/browser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r17787 r17809  
    338338
    339339#
    340 # Login/logout and language switch pages...
     340# Login/logout and language switch pages
    341341#
    342342
     
    532532
    533533#
    534 # Contact form...
     534# Contact form
    535535#
    536536
     
    624624
    625625#
    626 # University related pages...
     626# University related pages
    627627#
    628628
     
    840840
    841841#
    842 # User container pages...
     842# User container pages
    843843#
    844844
     
    11861186
    11871187#
    1188 # Search pages...
     1188# Search pages
    11891189#
    11901190
     
    12141214
    12151215#
    1216 # Configuration pages...
     1216# Configuration pages
    12171217#
    12181218
     
    13441344
    13451345#
    1346 # Datacenter pages...
     1346# Datacenter pages
    13471347#
    13481348
     
    14981498                return
    14991499            normalized_filename = self.getNormalizedFileName(filename)
     1500            if len(normalized_filename.split('.')[0]) > 65:
     1501                self.flash(_("Maximum file name length is 65 characters! "
     1502                             "Please choose a shorter file name."),
     1503                           type='danger')
     1504                return
    15001505            finished_file = os.path.join(
    15011506                self.context.storage, 'finished', normalized_filename)
     
    25582563
    25592564#
    2560 # Courses pages
    25612565#
    25622566class CoursePage(KofaDisplayFormPage, LocalRoleAssignmentUtilityView):
     
    27472751
    27482752#
    2749 # Certificate course pages...
     2753# CertificateCourse pages...
    27502754#
    27512755class CertificateCoursePage(KofaPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/datacenteruploadpage.pt

    r13813 r17809  
    3434  </div>
    3535</div>
    36 <br />
     36<br /><br />
     37<span i18n:translate="">
     38  Please note that the file name must not exceed 65 characters
     39  (including the officer's user name, which will become part of the file name).
     40</span>
    3741<form method="post" enctype="multipart/form-data">
    3842<br />
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r16818 r17809  
    225225        return
    226226
     227    def test_forbidden_filename(self):
     228        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     229        self.browser.open(self.datacenter_path)
     230        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     231        self.assertEqual(self.browser.url, self.datacenter_path)
     232        self.browser.getLink("Upload data").click()
     233        file = open(FORBIDDEN_FILE)
     234        ctrl = self.browser.getControl(name='uploadfile:file')
     235        file_ctrl = ctrl.mech_control
     236        file_ctrl.add_file(file, filename='123456789012345678901234567890123456789012345678901234567890123456.csv')
     237        self.browser.getControl('Upload').click()
     238        self.assertTrue(
     239            'Maximum file name length is 65 characters!'
     240            in self.browser.contents)
     241
    227242class DataCenterUIExportTests(UniversitySetup, FunctionalAsyncTestCase):
    228243    # Tests for DataCenter class views and pages.
Note: See TracChangeset for help on using the changeset viewer.