Ignore:
Timestamp:
1 Oct 2011, 06:28:16 (13 years ago)
Author:
Henrik Bettermann
Message:

Fill up student container in student module not in container module.

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  
    2020import os
    2121from zope.component.interfaces import IFactory
    22 from zope.securitypolicy.interfaces import IPrincipalRoleManager
    23 from hurry.workflow.interfaces import IWorkflowInfo
    24 from waeup.sirp.interfaces import IUserAccount
    2522from 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)
    3024from waeup.sirp.utils.helpers import get_current_principal
    3125from waeup.sirp.utils.logger import Logger
     
    5044            raise TypeError(
    5145                'StudentsContainers contain only IStudent instances')
    52         student.clearance_locked = True
    5346        self[student.student_id] = student
    54         studycourse = StudentStudyCourse()
    55         self[student.student_id]['studycourse'] = studycourse
    56         payments = StudentPayments()
    57         self[student.student_id]['payments'] = payments
    58         accommodation = StudentAccommodation()
    59         self[student.student_id]['accommodation'] = accommodation
    60         # Assign global student role for new student
    61         account = IUserAccount(student)
    62         account.roles = ['waeup.Student']
    63         # Assign local StudentRecordOwner role
    64         role_manager = IPrincipalRoleManager(self[student.student_id])
    65         role_manager.assignRoleToPrincipal(
    66             'waeup.local.StudentRecordOwner', student.student_id)
    6747        # Return student_id (only needed in tests)
    68         IWorkflowInfo(self[student.student_id]).fireTransition('create')
    6948        return student.student_id
    7049
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r6836 r6838  
    2121from zope.component.interfaces import IFactory
    2222from zope.interface import implementedBy
    23 from hurry.workflow.interfaces import IWorkflowState
    24 from waeup.sirp.interfaces import IObjectHistory
     23from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
     24from zope.securitypolicy.interfaces import IPrincipalRoleManager
     25from waeup.sirp.interfaces import IObjectHistory, IUserAccount
    2526from waeup.sirp.students.interfaces import (
    2627    IStudent, IStudentNavigation, IStudentClearanceEdit,
    2728    IStudentPersonalEdit)
     29from waeup.sirp.students.studycourse import StudentStudyCourse
     30from waeup.sirp.students.payments import StudentPayments
     31from waeup.sirp.students.accommodation import StudentAccommodation
    2832from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal
    2933from waeup.sirp.students.utils import generate_student_id
     
    9195        return implementedBy(Student)
    9296
     97@grok.subscribe(IStudent, grok.IObjectAddedEvent)
     98def 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
    93119@grok.subscribe(IStudent, grok.IObjectRemovedEvent)
    94120def removedStudentHandler(student, event):
     
    100126    grok.getSite()['students'].logger.info('%s - %s - %s' % (
    101127        user, target, comment))
     128    return
Note: See TracChangeset for help on using the changeset viewer.