Changeset 6838
- Timestamp:
- 1 Oct 2011, 06:28:16 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/container.py
r6836 r6838 20 20 import os 21 21 from zope.component.interfaces import IFactory 22 from zope.securitypolicy.interfaces import IPrincipalRoleManager23 from hurry.workflow.interfaces import IWorkflowInfo24 from waeup.sirp.interfaces import IUserAccount25 22 from waeup.sirp.students.interfaces import ( 26 IStudentsContainer, IStudent, IStudentPayments, IStudentAccommodation) 27 from waeup.sirp.students.studycourse import StudentStudyCourse 28 from waeup.sirp.students.payments import StudentPayments 29 from waeup.sirp.students.accommodation import StudentAccommodation 23 IStudentsContainer, IStudent) 30 24 from waeup.sirp.utils.helpers import get_current_principal 31 25 from waeup.sirp.utils.logger import Logger … … 50 44 raise TypeError( 51 45 'StudentsContainers contain only IStudent instances') 52 student.clearance_locked = True53 46 self[student.student_id] = student 54 studycourse = StudentStudyCourse()55 self[student.student_id]['studycourse'] = studycourse56 payments = StudentPayments()57 self[student.student_id]['payments'] = payments58 accommodation = StudentAccommodation()59 self[student.student_id]['accommodation'] = accommodation60 # Assign global student role for new student61 account = IUserAccount(student)62 account.roles = ['waeup.Student']63 # Assign local StudentRecordOwner role64 role_manager = IPrincipalRoleManager(self[student.student_id])65 role_manager.assignRoleToPrincipal(66 'waeup.local.StudentRecordOwner', student.student_id)67 47 # Return student_id (only needed in tests) 68 IWorkflowInfo(self[student.student_id]).fireTransition('create')69 48 return student.student_id 70 49 -
main/waeup.sirp/trunk/src/waeup/sirp/students/student.py
r6836 r6838 21 21 from zope.component.interfaces import IFactory 22 22 from zope.interface import implementedBy 23 from hurry.workflow.interfaces import IWorkflowState 24 from waeup.sirp.interfaces import IObjectHistory 23 from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo 24 from zope.securitypolicy.interfaces import IPrincipalRoleManager 25 from waeup.sirp.interfaces import IObjectHistory, IUserAccount 25 26 from waeup.sirp.students.interfaces import ( 26 27 IStudent, IStudentNavigation, IStudentClearanceEdit, 27 28 IStudentPersonalEdit) 29 from waeup.sirp.students.studycourse import StudentStudyCourse 30 from waeup.sirp.students.payments import StudentPayments 31 from waeup.sirp.students.accommodation import StudentAccommodation 28 32 from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal 29 33 from waeup.sirp.students.utils import generate_student_id … … 91 95 return implementedBy(Student) 92 96 97 @grok.subscribe(IStudent, grok.IObjectAddedEvent) 98 def addStudentHandler(student, event): 99 """If a student is added all subcontainers are automatically added 100 and the transition create is fired. The latter produces a logging message. 101 """ 102 student.clearance_locked = True 103 studycourse = StudentStudyCourse() 104 student['studycourse'] = studycourse 105 payments = StudentPayments() 106 student['payments'] = payments 107 accommodation = StudentAccommodation() 108 student['accommodation'] = accommodation 109 # Assign global student role for new student 110 account = IUserAccount(student) 111 account.roles = ['waeup.Student'] 112 # Assign local StudentRecordOwner role 113 role_manager = IPrincipalRoleManager(student) 114 role_manager.assignRoleToPrincipal( 115 'waeup.local.StudentRecordOwner', student.student_id) 116 IWorkflowInfo(student).fireTransition('create') 117 return 118 93 119 @grok.subscribe(IStudent, grok.IObjectRemovedEvent) 94 120 def removedStudentHandler(student, event): … … 100 126 grok.getSite()['students'].logger.info('%s - %s - %s' % ( 101 127 user, target, comment)) 128 return
Note: See TracChangeset for help on using the changeset viewer.