Last active
September 24, 2016 17:06
-
-
Save mjumbewu/24794fce12472c1d2a7bdcd620829f21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rejected = lambda r: r.action == 'Reject' | |
approved = lambda r: r.action == 'Approve' | |
expensive = lambda r: approved(r) and r.data['amount'] >= 500 | |
workflow( | |
roles=[ | |
'Employee', | |
'Supervisor', | |
'CFO', | |
'Travel Reviewer' ], | |
states=[ # The first state is always the initial state. | |
state( | |
name='Start', | |
view='https://cityofphiladelphia.github.io/workflow-views/travel-request.html', | |
then=[ | |
transition( | |
email='Supervisor', | |
goto='Supervisor Approval') ] ), | |
state( | |
name='Supervisor Approval', | |
view='templates/approve.html' | |
then=[ | |
transition( | |
when=expensive, | |
email='CFO', | |
goto='CFO Approval'), | |
transition( | |
when=approved, | |
email='Travel Reviewer', | |
goto='Travel Review Board Approval'), | |
transition( | |
when=rejected, | |
email='Employee', | |
goto='Rejected') ] ), | |
state( | |
name='CFO Approval', | |
view='templates/approve.html' | |
then=[ | |
transition( | |
when=approved, | |
email='Travel Reviewer', | |
goto='Travel Review Board Approval'), | |
transition( | |
when=rejected, | |
email='Employee', | |
goto='Rejected') ] ), | |
state( | |
name='Travel Review Board Approval', | |
view='templates/approve.html' | |
then=[ | |
transition( | |
when=approved, | |
email=['Employee', 'Supervisor'], | |
goto='Approved'), | |
transition( | |
when=rejected, | |
email='Employee', | |
goto='Rejected') ] ), | |
state( | |
name='Approved', | |
view='templates/approved.html' ), | |
state( | |
name='Rejected', | |
view='templates/rejected.html' ), | |
] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
roles: | |
- Employee | |
- Supervisor | |
- CFO | |
- Travel Reviewer | |
states: # The first state is always the initial state. | |
- name: Start | |
view: https://cityofphiladelphia.github.io/workflow-views/travel-request.html | |
then: | |
- email: Supervisor | |
goto: Supervisor Approval | |
- name: Supervisor Approval | |
view: templates/approve.html | |
then: | |
- when: function(r) { approved(r) && r.data.amount >= 500; } | |
email: CFO | |
goto: CFO Approval | |
- when: approved | |
email: Travel Reviewer | |
goto: Travel Review Board Approval | |
- when: rejected | |
email: Employee | |
goto: Rejected | |
- name: CFO Approval | |
view: templates/approve.html | |
then: | |
- when: approved | |
email: Travel Reviewer | |
goto: Travel Review Board Approval | |
- when: rejected | |
email: Employee | |
goto: Rejected | |
- name: Travel Review Board Approval | |
view: templates/approve.html | |
then: | |
- when: approved | |
email: | |
- Employee | |
- Supervisor | |
goto: Travel Review Board Approval | |
- when: rejected | |
email: Employee | |
goto: Rejected | |
- name: Approved | |
view: templates/approved.html | |
- name: Rejected | |
view: templates/rejected.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment