Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asifpy/django-simpleflow
Simple workflow engine
https://github.com/asifpy/django-simpleflow
Last synced: 6 days ago
JSON representation
Simple workflow engine
- Host: GitHub
- URL: https://github.com/asifpy/django-simpleflow
- Owner: asifpy
- License: apache-2.0
- Created: 2016-09-20T06:23:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-20T06:27:21.000Z (over 8 years ago)
- Last Synced: 2024-11-17T01:51:28.803Z (about 2 months ago)
- Language: JavaScript
- Size: 292 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
===================
django-simpleflow
===================This is a work-in-progress code branch of `django-simpleflow` as a third-party app, which aims to bring generic workflow engine using `Django`.
Prerequisites
-------------
- Django 1.8+
- Python 2.7+, 3.2+
- Django Tables2Usage
-----**Add "simpleflow" to INSTALLED_APPS**
.. code-block:: python
INSTALLED_APPS = {
...
'django_tables2',
'simpleflow'
}PROJECT_NAME = 'YOUR PROJECT NAME'
**Define your process with its states**
.. code-block:: python
from leave.handlers import(
update_leaverequest_after_hr_approval,
update_leaverequest_after_manager_approval
)PROCESS = {
'initial': {
'name': 'Manager Approval',
'on_completion': [update_leaverequest_after_manager_approval],
'group': 'Manager',
'next_transition': 'hr_approver'
# if 'form' is not defined, then simpleflow
# will use default ApprovalForm
},
'hr_approver': {
'form': HrApprovalForm,
'name': 'HR Approval',
'on_completion': [update_leaverequest_after_hr_approval],
'group': 'HR'
}
}**Assign the above defined process to the model**
.. code-block:: python
from simpleflow.models import SimpleFlow
from leave import processclass LeaveRequest(SimpleFlow):
# assign your process here
PROCESS = process.PROCESSemployee = models.ForeignKey(
Employee,
blank=True,
null=True,
related_name='leave_requests'
)
leave_type = models.CharField(
max_length=50,
choices=[
('S', 'Sick'),
('V', 'Vacation'),
('W', 'Wedding / Marriage'),
]
)
leave_from = models.DateTimeField()
leave_to = models.DateTimeField()# trigger simpleflow
def submit_for_approval(self):
self.status = "submitted_for_approval"
self.save()# start simpleflow
# this will create task for initial state which
# you defined in your PROCESS config
self.start_simpleflow()