Changeset 7391 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 19 Dec 2011, 12:26:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py
r7388 r7391 18 18 import os 19 19 import grok 20 from cStringIO import StringIO 20 21 from grok import index 21 from zope.component import getUtility 22 from zope.component import getUtility, createObject, getUtility, getAdapter 22 23 from zope.component.interfaces import IFactory 23 from zope.component import createObject, getUtility24 24 from zope.catalog.interfaces import ICatalog 25 25 from zope.securitypolicy.interfaces import IPrincipalRoleManager … … 31 31 from waeup.sirp.interfaces import ( 32 32 IObjectHistory, IFileStoreHandler, IFileStoreNameChooser, ISIRPUtils, 33 IExtFileStore) 33 IExtFileStore, IPDF) 34 from waeup.sirp.students.vocabularies import RegNumNotInSource 34 35 from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal 35 36 from waeup.sirp.applicants.interfaces import ( 36 37 IApplicant, IApplicantEdit, IApplicantBaseData, 37 38 ) 38 from waeup.sirp.students.vocabularies import RegNumNotInSource 39 39 40 40 41 class Applicant(grok.Container): … … 77 78 return sirp_utils.fullname(self.firstname, self.lastname, middlename) 78 79 79 def createStudent(self ):80 def createStudent(self, view=None): 80 81 """Create a student, fill with base data, create a StudentApplication 81 82 object and copy applicant data. … … 96 97 site = grok.getSite() 97 98 site['students'].addStudent(student) 98 # Fill student_id 99 99 100 self.student_id = student.student_id 100 # Fire transition 'create'101 101 IWorkflowInfo(self).fireTransition('create') 102 102 103 # Copy some base data 103 104 student.firstname = self.firstname … … 107 108 student.email = self.email 108 109 student.phone = self.phone 110 109 111 # Save the certificate 110 112 student['studycourse'].certificate = self.course_admitted 111 113 self._copyPassportImage(student) 112 114 113 # Save application slip (ExportPDFPage) 115 # Save application slip 116 self._createApplicationPDF(student, view=view) 114 117 115 118 return True, 'Student %s created' % student.student_id 119 120 def _createApplicationPDF(self, student, view=None): 121 """Create an application slip as PDF and store it in student folder. 122 """ 123 file_store = getUtility(IExtFileStore) 124 applicant_slip = getAdapter(self, IPDF, name='application_slip')( 125 view=view) 126 file_id = IFileStoreNameChooser(student).chooseName( 127 attr="application_slip.pdf") 128 file_store.createFile(file_id, StringIO(applicant_slip)) 129 return 116 130 117 131 def _copyPassportImage(self, student):
Note: See TracChangeset for help on using the changeset viewer.