Changeset 15941 for main/waeup.kofa/trunk
- Timestamp:
- 20 Jan 2020, 14:01:54 (5 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r15932 r15941 4 4 1.6.1.dev0 (unreleased) 5 5 ======================= 6 7 * Copy also files from applicants to students section. 6 8 7 9 * Reset _curr_stud_id if student could not be created. -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/applicant.py
r15932 r15941 40 40 from waeup.kofa.utils.helpers import attrs_to_fields 41 41 from waeup.kofa.applicants.interfaces import ( 42 IApplicant, IApplicantEdit, ISpecialApplicant )42 IApplicant, IApplicantEdit, ISpecialApplicant, IApplicantsUtils) 43 43 from waeup.kofa.applicants.workflow import application_states_dict 44 44 from waeup.kofa.applicants.payment import ApplicantOnlinePayment … … 153 153 154 154 def createStudent(self, view=None): 155 """Create a student, fill with base data, create an application slip 156 and copy applicant data.155 """Create a student, fill with base data, create an application slip, 156 copy applicant data and files. 157 157 """ 158 158 site = grok.getSite() … … 218 218 self._setStudyCourseAttributes(student['studycourse']) 219 219 self._copyPassportImage(student) 220 self._copyFiles(student) 220 221 # Update the catalog 221 222 notify(grok.ObjectModifiedEvent(student)) … … 247 248 return 248 249 250 def _copyFiles(self, student): 251 """Copy all other files over to student location. Not 252 used in base package but tested with fake file. 253 """ 254 file_store = getUtility(IExtFileStore) 255 filenames = getUtility(IApplicantsUtils).FILENAMES 256 for filename in filenames: 257 appl_file = file_store.getFileByContext(self, attr=filename) 258 if appl_file is None: 259 return 260 stud_file_id = IFileStoreNameChooser(student).chooseName( 261 attr=filename) 262 file_store.createFile(stud_file_id, appl_file) 263 return 264 249 265 # Set all attributes of Applicant required in IApplicant as field 250 266 # properties. Doing this, we do not have to set initial attributes … … 345 361 In the beginning the `attr` parameter was not taken into account for 346 362 :class:`Applicant` context as the single passport image was the 347 only file we store for applicants. Meanwhile FUTMinna requires363 only file we store for applicants. Meanwhile many universities require 348 364 uploads of other documents too. Now we store passport image 349 365 files without attribute but all other documents with. … … 439 455 file_store = getUtility(IExtFileStore) 440 456 file_store.deleteFileByContext(applicant) 457 # Remove all other files too 458 459 441 460 # Remove global role 442 461 role_manager = IPrincipalRoleManager(grok.getSite()) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py
r15932 r15941 21 21 import os 22 22 import grok 23 from StringIO import StringIO 23 24 from datetime import datetime 24 25 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState … … 59 60 self.prepare_applicant() 60 61 storage = getUtility(IExtFileStore) 62 # The stored image can be fetched 61 63 file_id = IFileStoreNameChooser(self.applicant).chooseName() 62 # The stored image can be fetched63 64 fd = storage.getFile(file_id) 64 65 file_len_orig = len(fd.read()) 66 # We store a test pdf file 67 dummy_file = StringIO('test file') 68 testfile_id = IFileStoreNameChooser( 69 self.applicant).chooseName(attr='testfile.pdf') 70 test_file = storage.createFile(testfile_id, dummy_file) 71 # The stored file can be fetched 72 fd = storage.getFile(testfile_id) 73 testfile_len_orig = len(fd.read()) 65 74 self.assertEqual(self.app['students']._curr_stud_id, 1000000) 66 75 # Let's try to create the student … … 111 120 self.assertEqual(self.applicant.student_id, student.student_id) 112 121 # Check if passport image has been copied 113 storage = getUtility(IExtFileStore) 114 file_id = IFileStoreNameChooser( 115 student).chooseName(attr='passport.jpg') 122 file_id = IFileStoreNameChooser(student).chooseName(attr='passport.jpg') 116 123 fd = storage.getFile(file_id) 117 124 file_len = len(fd.read()) 118 125 self.assertEqual(file_len_orig, file_len) 126 # Check if test file has been copied too (new) 127 file_id = IFileStoreNameChooser(student).chooseName(attr='testfile.jpg') 128 fd = storage.getFile(file_id) 129 file_len = len(fd.read()) 130 self.assertEqual(testfile_len_orig, file_len) 119 131 # Check if application slip exists and is a PDF file 120 132 file_id = IFileStoreNameChooser( -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py
r14281 r15941 47 47 'form.notice': _(u'Application Process Data'), 48 48 } 49 50 #: A tuple of names of files to be copied over 51 #: to students section. 52 FILENAMES = ('testfile.pdf',) 49 53 50 54 def setPaymentDetails(self, container, payment, applicant): -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r15918 r15941 2174 2174 2175 2175 This view is used for browser tests only and 2176 must be neutralized in custom pages!2176 must be neutralized on custom pages! 2177 2177 """ 2178 2178 grok.name('fake_approve')
Note: See TracChangeset for help on using the changeset viewer.