Package: django-river
Django RiverRiver is an open source workflow framework forDjangowhich supports on
the fly changes instead of hard-coding states, transitions and authorization rules.The main goal of developing this framework isto be able to modify literally everything
about the workflows on the fly.This means that all the elements in a workflow like
states, transitions or authorizations rules are editable at any time so that no changes
requires a re-deploying of your application anymore.Playground: There is a fake jira example repository as a playground of django-river.https://github.com/javrasya/fakejiraDonationsThis is a fully open source project and it can be better with your donations.If you are usingdjango-riverto create a commercial product,
please consider becoming oursponsor,patronor donate overPayPalDocumentationOnline documentation is available athttp://django-river.rtfd.org/Advance AdminA very modern admin with some user friendly interfaces that is calledRiver Adminhas been published.RequirementsPython (3.5(for Django2.2only),3.6,3.7,3.8)Django (2.2,3.0,3.1)Django= 2.2 is supported forPython>= 3.5Django>= 3.0 is supported forPython>= 3.6Supported (Tested) Databases:PostgreSQLTestedSupport9✅✅10✅✅11✅✅12✅✅MySQLTestedSupport5.6✅❌5.7✅❌8.0✅✅MSSQLTestedSupport19✅✅17✅✅UsageInstall and enable itpipinstalldjango-riverINSTALLED_APPS=[...river...]Create your first state machine in your model and migrate your dbfromdjango.dbimportmodelsfromriver.models.fields.stateimportStateFieldclassMyModel(models.Model):my_state_field=StateField()Create all yourstateson the admin pageCreate aworkflowwith your model (MyModel-my_state_field) information on the admin pageCreate yourtransition metadatawithin the workflow created earlier, source and destination statesCreate yourtransition approval metadatawithin the workflow created earlier and authorization rules along with their priority on the admin pageEnjoy yourdjango-riverjourney.my_model=MyModel.objects.get(....)my_model.river.my_state_field.approve(as_user=transactioner_user)my_model.river.my_state_field.approve(as_user=transactioner_user,next_state=State.objects.get(label='re-opened'))# and much more. Check the documentationNoteWhenever a model object is saved, it’s state field will be initialized with the
state is given at step-4 above bydjango-river.Hooking Up With The Eventsdjango-riverprovides you to have your custom code run on certain events. And since version v2.1.0 this has also been supported for on the fly changes. You can
create your functions and also the hooks to a certain events by just creating few database items. Let’s see what event types that can be hooked a function to;An approval is approvedA transition goes throughThe workflow is completeFor all these event types, you can create a hooking with a given function which is created separately and preliminary than the hookings for all the workflow objects you have
or you will possible have, or for a specific workflow object. You can also hook up before or after the events happen.1. Create FunctionThis will be the description of your functions. So you define them once and you can use them with multiple hooking up. Just go to/admin/river/function/admin page
and create your functions there.django-riverfunction admin support python code highlights.INSTALLED_APPS=[...codemirror2river...]Here is an example function;fromdatetimeimportdatetimedefhandle(context):print(datetime.now())Important:YOUR FUNCTION SHOULD BE NAMED AShandle. Otherwisedjango-riverwon’t execute your function.django-riverwill pass acontextdown to your function in order for you to know why the function is triggered or for which object or so. And thecontextwill look different for
different type of events. Please see detailedcontext documentationto know more on what you would get from context in your functions.You can find anadvance function exampleon the link.2. Hook It UpThe hookings indjango-rivercan be created both specifically for a workflow object or for a whole workflow.django-rivercomes with some model objects and admin interfaces which you can use
to create the hooks.To create one for whole workflow regardless of what the workflow object is, go to/admin/river/onapprovedhook/to hook up to an approval/admin/river/ontransithook/to hook up to a transition/admin/river/oncompletehook/to hook up to the completion of the workflowTo create one for a specific workflow object you should use the admin interface for the workflow object itself. One amazing feature ofdjango-riveris now that it creates a default admin interface with the hookings for your workflow model class. If you have already defined one,django-riverenriches your already defined admin with the hooking section. It is default disabled. To enable it just defineRIVER_INJECT_MODEL_ADMINto beTruein thesettings.py.Note:They can programmatically be created as well since they are model objects. If it is needed to be at workflow level, just don’t provide the workflow object column. If it is needed
to be for a specific workflow object then provide it.Here are the list of hook models;OnApprovedHookOnTransitHookOnCompleteHookBefore Reporting A Bugdjango-riverhas behavioral tests that are very easy to read and write. One can easily set up one
and see if everything is running as expected. Please look at other examples (that are the files with.featurepostfix)
underfeaturesfolder that you can get all the inspiration and create one for yourself before you open an issue
Then refer to your behavioral test to point out what is not function as expected to speed the process up for your own
sake. It is even better to name it with your issue number so we can persist it in the repository.Migrations2.X.X to 3.0.0django-riverv3.0.0 comes with quite number of migrations, but the good news is that even though those are hard to determine kind of migrations, it comes with the required migrations
out of the box. All you need to do is to run;pythonmanage.pymigrateriver3.1.X to 3.2.Xdjango-riverstarted to supportMicrosoft SQL Server 17 and 19after version 3.2.0 but the previous migrations didn’t get along with it. We needed to reset all
the migrations to have fresh start. If you have already migrated to version3.1.Xall you need to do is to pull your migrations back to the beginning.pythonmanage.pymigrate--fakeriverzeropythonmanage.pymigrate--fakeriverFAQHave a look atFAQContributorsCode ContributorsThis project exists thanks to all the people who contribute :rocket: :heart:Financial ContributorsBecome a financial contributor and help us sustain our community.ContributeIndividualsOrganizationsSupport this project with your organization. Your logo will show up here with a link to your website.ContributeLicenseThis software is licensed under theNew BSD License. See theLICENSEfile in the top distribution directory for the full license text.