1 | """Workflow for students. |
---|
2 | """ |
---|
3 | import grok |
---|
4 | from datetime import datetime |
---|
5 | from zope.component import getUtility |
---|
6 | from hurry.workflow.workflow import Transition, WorkflowState, NullCondition |
---|
7 | from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent |
---|
8 | from waeup.kofa.interfaces import ( |
---|
9 | IObjectHistory, IKofaWorkflowInfo, IKofaUtils, |
---|
10 | CREATED, ADMITTED, CLEARANCE, REQUESTED, CLEARED, PAID, RETURNING, |
---|
11 | REGISTERED, VALIDATED, GRADUATED, TRANSCRIPT) |
---|
12 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
13 | from waeup.kofa.workflow import KofaWorkflow, KofaWorkflowInfo |
---|
14 | from waeup.kofa.students.interfaces import IStudent, IStudentsUtils |
---|
15 | from waeup.kofa.students.workflow import RegistrationWorkflowInfo |
---|
16 | |
---|
17 | |
---|
18 | REGISTRATION_TRANSITIONS = ( |
---|
19 | Transition( |
---|
20 | transition_id = 'create', |
---|
21 | title = _('Create customer'), |
---|
22 | source = None, |
---|
23 | condition = NullCondition, |
---|
24 | msg = _('Record created'), |
---|
25 | destination = CREATED), |
---|
26 | |
---|
27 | Transition( |
---|
28 | transition_id = 'admit', |
---|
29 | title = _('Approve subscription'), |
---|
30 | msg = _('Subscription approved'), |
---|
31 | source = CREATED, |
---|
32 | destination = CLEARED), |
---|
33 | |
---|
34 | Transition( |
---|
35 | transition_id = 'reset1', |
---|
36 | title = _('Reset customer to initial state'), |
---|
37 | msg = _('Reset to initial state'), |
---|
38 | source = CLEARED, |
---|
39 | destination = CREATED), |
---|
40 | |
---|
41 | Transition( |
---|
42 | transition_id = 'pay_first_school_fee', |
---|
43 | title = _('Pay first meter fee'), |
---|
44 | msg = _('First meter fee payment made'), |
---|
45 | source = CLEARED, |
---|
46 | destination = PAID), |
---|
47 | |
---|
48 | Transition( |
---|
49 | transition_id = 'approve_first_school_fee', |
---|
50 | title = _('Approve first meter payment'), |
---|
51 | msg = _('First meter fee payment approved'), |
---|
52 | source = CLEARED, |
---|
53 | destination = PAID), |
---|
54 | |
---|
55 | # The pg fee payment has proper handlers which suit |
---|
56 | # customer payments. |
---|
57 | |
---|
58 | Transition( |
---|
59 | transition_id = 'pay_pg_fee', |
---|
60 | title = _('Pay meter fee'), |
---|
61 | msg = _('Meter fee paid'), |
---|
62 | source = PAID, |
---|
63 | destination = PAID), |
---|
64 | |
---|
65 | Transition( |
---|
66 | transition_id = 'approve_pg_fee', |
---|
67 | title = _('Approve meter fee payment'), |
---|
68 | msg = _('Meter fee payment approved'), |
---|
69 | source = PAID, |
---|
70 | destination = PAID), |
---|
71 | |
---|
72 | Transition( |
---|
73 | transition_id = 'reset2', |
---|
74 | title = _("Reset customer to state 'subscription approved'"), |
---|
75 | msg = _("Reset to state 'subscription approved'"), |
---|
76 | source = PAID, |
---|
77 | destination = CLEARED), |
---|
78 | ) |
---|
79 | |
---|
80 | |
---|
81 | registration_workflow = KofaWorkflow(REGISTRATION_TRANSITIONS) |
---|
82 | |
---|
83 | class CustomRegistrationWorkflowInfo(RegistrationWorkflowInfo): |
---|
84 | """Adapter to adapt Student objects to workflow info objects. |
---|
85 | """ |
---|
86 | |
---|
87 | def __init__(self, context): |
---|
88 | self.context = context |
---|
89 | self.wf = registration_workflow |
---|