- Timestamp:
- 13 Jul 2021, 14:08:06 (3 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r16538 r16545 4 4 1.7.2.dev0 (unreleased) 5 5 ======================= 6 7 * Enable applicants to upload also additional jpg files. 6 8 7 9 * Prefill login form after applicant registration. … … 17 19 * Sort attendance.pdf first by faculty and department before certcode. 18 20 19 * Add serial o to the coursetickets.pdf.21 * Add serial no to the coursetickets.pdf. 20 22 21 23 1.7.1 (2021-04-20) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/applicant.py
r16282 r16545 299 299 if appl_file is None: 300 300 continue 301 ext = os.path.splitext(appl_file.name)[1] 301 302 stud_file_id = IFileStoreNameChooser(student).chooseName( 302 attr=filename[1] )303 attr=filename[1] + ext) 303 304 file_store.createFile(stud_file_id, appl_file) 304 305 return -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r16539 r16545 43 43 IApplicantRefereeReport 44 44 ) 45 from waeup.kofa.utils.helpers import html2dict 45 from waeup.kofa.utils.helpers import (html2dict, 46 string_from_bytes, file_size, get_fileformat) 46 47 from waeup.kofa.applicants.container import ( 47 48 ApplicantsContainer, VirtualApplicantsExportJobContainer) … … 996 997 view.flash(_('Uploaded file is too big!')) 997 998 return False 998 dummy, ext = os.path.splitext(upload.filename) 999 upload.seek(0) # file pointer moved when determining size 1000 dummy,ext = os.path.splitext(upload.filename) 1001 file_format = get_fileformat(None, upload.read(512)) 1002 upload.seek(0) # same here 1003 if file_format is None: 1004 view.flash(_('Could not determine file type.'), type="danger") 1005 return False 999 1006 ext.lower() 1000 if ext != '.pdf':1001 view.flash(_('pdf file extension expected.'), type='danger')1007 if ext not in ('.pdf', '.jpg'): 1008 view.flash(_('pdf or jpg file extension expected.'), type='danger') 1002 1009 return False 1003 upload.seek(0) # file pointer moved when determining size1010 download_name = attr + '.' + file_format 1004 1011 store = getUtility(IExtFileStore) 1005 file_id = IFileStoreNameChooser(context).chooseName(attr= attr)1012 file_id = IFileStoreNameChooser(context).chooseName(attr=download_name) 1006 1013 store.createFile(file_id, upload) 1007 1014 return True … … 2074 2081 2075 2082 class AdditionalFile(grok.View): 2076 """Renders additional pdffiles for applicants.2083 """Renders additional files for applicants. 2077 2084 This is a baseclass. 2078 2085 """ … … 2082 2089 2083 2090 def render(self): 2084 pdf = getUtility(IExtFileStore).getFileByContext( 2091 #image = getUtility(IExtFileStore).getFileByContext( 2092 # self.context, attr=self.download_name) 2093 file = getUtility(IExtFileStore).getFileByContext( 2085 2094 self.context, attr=self.__name__) 2086 self.response.setHeader('Content-Type', 'application/pdf') 2087 return pdf 2095 dummy,ext = os.path.splitext(file.name) 2096 if ext == '.jpg': 2097 self.response.setHeader('Content-Type', 'image/jpeg') 2098 elif ext == '.pdf': 2099 self.response.setHeader('Content-Type', 'application/pdf') 2100 return file 2088 2101 2089 2102 class TestFile(AdditionalFile): 2090 """Renders testfile. pdf.2091 """ 2092 grok.name('testfile .pdf')2103 """Renders testfile. 2104 """ 2105 grok.name('testfile') -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicanteditpage.pt
r16133 r16545 54 54 <p tal:condition="python:view.file_exists(filename[1])"> 55 55 <a tal:attributes="href python:filename[1]"i18n:translate=""> 56 Download pdffile56 Download file 57 57 </a> 58 58 </p> … … 67 67 </div> 68 68 <span i18n:translate=""> 69 PDF files only. Max. file size:69 JPG or PDF files only. Max. file size: 70 70 </span> 71 71 <span tal:replace="view/max_file_upload_size">10 KB</span> -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py
r16228 r16545 67 67 dummy_file = StringIO('test file') 68 68 testfile_id = IFileStoreNameChooser( 69 self.applicant).chooseName(attr='testfile. pdf')69 self.applicant).chooseName(attr='testfile.jpg') 70 70 test_file = storage.createFile(testfile_id, dummy_file) 71 71 # The stored file can be fetched -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r16526 r16545 1322 1322 pdf_content = 'A' * 1024 * 300 # A string of 300 KB size 1323 1323 pseudo_pdf = StringIO(pdf_content) 1324 ctrl = self.browser.getControl(name='testfile .pdf')1324 ctrl = self.browser.getControl(name='testfile') 1325 1325 file_ctrl = ctrl.mech_control 1326 file_ctrl.add_file(pseudo_pdf, filename=' testfile.pdf')1326 file_ctrl.add_file(pseudo_pdf, filename='my_file.pdf') 1327 1327 self.browser.getControl("Save").click() # submit form 1328 1328 self.assertTrue('Uploaded file is too big!' 1329 1329 in self.browser.contents) 1330 pdf_content = 'A' * 1024 * 200 # A string of 300 KB size 1331 pseudo_pdf = StringIO(pdf_content) 1332 ctrl = self.browser.getControl(name='testfile.pdf') 1330 #pdf_content = 'A' * 1024 * 200 # A string of 300 KB size 1331 #pseudo_pdf = StringIO(pdf_content) 1332 image = open(SAMPLE_IMAGE, 'rb') 1333 ctrl = self.browser.getControl(name='testfile') 1333 1334 file_ctrl = ctrl.mech_control 1334 file_ctrl.add_file( pseudo_pdf, filename='testfile.pdf')1335 file_ctrl.add_file(image, filename='my_scan.jpg') 1335 1336 self.browser.getControl("Save").click() # submit form 1336 1337 # The file has been successfully uploaded … … 1339 1340 storage = getUtility(IExtFileStore) 1340 1341 file_id = IFileStoreNameChooser(self.applicant).chooseName( 1341 attr='testfile. pdf')1342 attr='testfile.jpg') 1342 1343 # The stored file can be fetched 1343 1344 fd = storage.getFile(file_id) 1344 1345 file_len = len(fd.read()) 1345 self.assertEqual(file_len, 2 04800)1346 self.assertEqual(file_len, 2787) 1346 1347 # A file link is displayed on the edit view ... 1347 1348 self.browser.open(self.edit_path) 1348 self.assertTrue('<a href="testfile .pdf">' in self.browser.contents)1349 self.assertTrue('<a href="testfile">' in self.browser.contents) 1349 1350 # ... and on the dislay view 1350 1351 self.browser.open(self.view_path) 1351 self.assertTrue('testfile .pdf">Test File</a>'1352 self.assertTrue('testfile">Test File</a>' 1352 1353 in self.browser.contents) 1353 1354 # Adding file is properly logged … … 1357 1358 self.assertTrue( 1358 1359 '%s - applicants.browser.ApplicantEditFormPage' 1359 ' - %s - saved: testfile .pdf'1360 ' - %s - saved: testfile' 1360 1361 % (self.applicant.applicant_id, self.applicant.applicant_id) 1361 1362 in logcontent) 1362 # When an applicant is removed, also the pdffiles are gone.1363 # When an applicant is removed, also the files are gone. 1363 1364 del self.applicantscontainer[self.applicant.application_number] 1364 1365 fd = storage.getFile(file_id) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py
r16415 r16545 54 54 #: A tuple of tuple of file names to be uploaded by applicants and copied 55 55 #: over to the students section. 56 ADDITIONAL_FILES = (('Test File','testfile .pdf'),)56 ADDITIONAL_FILES = (('Test File','testfile'),) 57 57 58 58 def setPaymentDetails(self, container, payment, applicant):
Note: See TracChangeset for help on using the changeset viewer.