Ignore:
Timestamp:
20 Sep 2012, 08:49:37 (12 years ago)
Author:
uli
Message:

Merge changes from update branch (includes trunk changes until r9107).

Location:
main/waeup.kofa/branches/uli-zc-async
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-zc-async

  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/workflow.py

    r8471 r9209  
    22"""
    33import grok
     4from datetime import datetime
    45from zope.component import getUtility
    56from hurry.workflow.workflow import Transition, WorkflowState, NullCondition
     
    1213from waeup.kofa.workflow import KofaWorkflow, KofaWorkflowInfo
    1314from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
     15from waeup.kofa.utils.helpers import get_current_principal
    1416
    1517
    1618IMPORTABLE_STATES = (ADMITTED, CLEARANCE, REQUESTED, CLEARED, PAID, RETURNING,
    1719    REGISTERED, VALIDATED)
     20
     21FORBIDDEN_POSTGRAD_STATES = (RETURNING, REGISTERED, VALIDATED)
    1822
    1923REGISTRATION_TRANSITIONS = (
     
    2327        source = None,
    2428        condition = NullCondition,
    25         msg = _('Student record created'),
     29        msg = _('Record created'),
    2630        destination = CREATED),
    2731
     
    2933        transition_id = 'admit',
    3034        title = _('Admit student'),
    31         msg = _('Student admitted'),
     35        msg = _('Admitted'),
    3236        source = CREATED,
    3337        destination = ADMITTED),
     
    6367    Transition(
    6468        transition_id = 'reset3',
    65         title = _('Reset to clearance'),
    66         msg = _("Reset to 'clearance'"),
     69        title = _('Reset to clearance started'),
     70        msg = _("Reset to 'clearance started'"),
    6771        source = REQUESTED,
    6872        destination = CLEARANCE),
     
    7781    Transition(
    7882        transition_id = 'reset4',
    79         title = _('Reset to clearance'),
    80         msg = _("Reset to 'clearance'"),
     83        title = _('Reset to clearance started'),
     84        msg = _("Reset to 'clearance started'"),
    8185        source = CLEARED,
    8286        destination = CLEARANCE),
     
    8589        transition_id = 'pay_first_school_fee',
    8690        title = _('Pay school fee'),
    87         msg = _('School fee paid'),
     91        msg = _('First school fee payment made'),
    8892        source = CLEARED,
    8993        destination = PAID),
     
    9296        transition_id = 'approve_first_school_fee',
    9397        title = _('Approve payment'),
    94         msg = _('School fee payment approved'),
     98        msg = _('First school fee payment approved'),
    9599        source = CLEARED,
    96100        destination = PAID),
     
    106110        transition_id = 'pay_school_fee',
    107111        title = _('Pay school fee'),
    108         msg = _('Payment made'),
     112        msg = _('School fee payment made'),
    109113        source = RETURNING,
    110114        destination = PAID),
     
    112116    Transition(
    113117        transition_id = 'pay_pg_fee',
    114         title = _('Pay postgraduate school fee'),
    115         msg = _('Payment made'),
     118        title = _('Pay PG school fee'),
     119        msg = _('PG school fee payment made'),
    116120        source = PAID,
    117121        destination = PAID),
     
    119123    Transition(
    120124        transition_id = 'approve_school_fee',
    121         title = _('Approve payment'),
     125        title = _('Approve school fee payment'),
    122126        msg = _('School fee payment approved'),
    123127        source = RETURNING,
     
    126130    Transition(
    127131        transition_id = 'approve_pg_fee',
    128         title = _('Approve postgraduate payment'),
    129         msg = _('School fee payment approved'),
     132        title = _('Approve PG school fee payment'),
     133        msg = _('PG school fee payment approved'),
    130134        source = PAID,
    131135        destination = PAID),
     
    147151    Transition(
    148152        transition_id = 'reset7',
    149         title = _('Reset to paid'),
    150         msg = _("Reset to 'paid'"),
     153        title = _('Reset to school fee paid'),
     154        msg = _("Reset to 'school fee paid'"),
    151155        source = REGISTERED,
    152156        destination = PAID),
     
    161165    Transition(
    162166        transition_id = 'reset8',
    163         title = _('Reset to paid'),
    164         msg = _("Reset to 'paid'"),
     167        title = _('Reset to school fee paid'),
     168        msg = _("Reset to 'school fee paid'"),
    165169        source = VALIDATED,
    166170        destination = PAID),
     
    175179    Transition(
    176180        transition_id = 'reset9',
    177         title = _('Reset to validated'),
    178         msg = _("Reset to 'validated'"),
     181        title = _('Reset to courses validated'),
     182        msg = _("Reset to 'courses validated'"),
    179183        source = RETURNING,
    180184        destination = VALIDATED),
     
    183187IMPORTABLE_TRANSITIONS = [i.transition_id for i in REGISTRATION_TRANSITIONS]
    184188
     189FORBIDDEN_POSTGRAD_TRANS = ['reset6', 'register_courses']
    185190LOCK_CLEARANCE_TRANS = ('reset2', 'request_clearance')
    186191UNLOCK_CLEARANCE_TRANS = ('reset3', 'reset4', 'start_clearance')
     
    212217
    213218    Lock and unlock clearance form.
    214     Triger actions after school fee payment.
     219    Trigger actions after school fee payment.
    215220    """
    216221
     
    231236        new_session = obj['studycourse'].current_session + 1
    232237        obj['studycourse'].current_session = new_session
     238    elif event.transition.transition_id == 'validate_courses':
     239        current_level = obj['studycourse'].current_level
     240        level_object = obj['studycourse'].get(str(current_level), None)
     241        if level_object is not None:
     242            user = get_current_principal()
     243            if user is None:
     244                usertitle = 'system'
     245            else:
     246                usertitle = getattr(user, 'public_name', None)
     247                if not usertitle:
     248                    usertitle = user.title
     249            level_object.validated_by = usertitle
     250            level_object.validation_date = datetime.utcnow()
     251    elif event.transition.transition_id == 'reset8':
     252        current_level = obj['studycourse'].current_level
     253        level_object = obj['studycourse'].get(str(current_level), None)
     254        if level_object is not None:
     255            level_object.validated_by = None
     256            level_object.validation_date = None
    233257    # In some tests we don't have a students container
    234258    try:
Note: See TracChangeset for help on using the changeset viewer.