Giter Site home page Giter Site logo

faxad / activflow Goto Github PK

View Code? Open in Web Editor NEW
564.0 56.0 93.0 949 KB

Generic, light-weight & extensible Workflow Engine for agile automation of Business Processes | Django, Python

License: Other

Python 24.95% JavaScript 52.02% HTML 5.92% Dockerfile 0.14% CSS 16.85% Shell 0.12%
workflow django python bpm

activflow's Introduction

activflow

Build Status Coverage Status Codacy Badge FOSSA Status

Introduction

ActivFlow is a generic, light-weight and extensible workflow engine for agile development and automation of complex Business Process operations.

Developers can emphasize towards mapping the Business Process model as ActivFlow workflow without having to worry about implementing the core workflow processing logic. The generic implementation of the workflow engine manages the automation of the Business Processes from start to finish in accordance with the defined flow.

What is an ActivFlow workflow?

  • Business Process flow mapped as ActivFlow configuration
  • Definition of data to be captured for each activity (state)
  • Business Roles mapped to workflow activities
  • Rules applied on transitions between activities

alt tag

Technology Stack

  • Python 3.6+
  • Django 3.x
  • Bootstrap 3.x

Usage & Configuration

Step 1: Workflow App Registration

  • A Business Process must be represented in terms of a Django app
  • All apps must be registered to WORKFLOW_APPS under core/constants
WORKFLOW_APPS = ['leave_request']

Step 2: Activity Configuration

  • Activities (States/Nodes) are represented as Django models
  • Activity must inherit from AbstractInitialActivity/AbstractActivity respectively
  • Custom validation logic must be defined under clean() on the activity model
  • Custom field specific validation should go under app/validator and applied to the field as validators attribute
from activflow.core.models import AbstractActivity, AbstractInitialActivity, AbstractEntity
from activflow.leave_request.validators import validate_initial_cap

class SampleRequest(AbstractInitialActivity):
    """Sample leave request details"""
    employee_name = CharField("Employee", max_length=200, validators=[validate_initial_cap])
    from = DateField("From Date")
    to = DateField("To Date")
    reason = TextField("Purpose of Leave", blank=True)

    def clean(self):
        """Custom validation logic should go here"""
        pass

class Itinerary(AbstractEntity):
    """Itinerary details"""
    request = ForeignKey(RequestInitiation, related_name="itineraries")
    destination = CharField("Destination", max_length=200)
    date = DateField("Visit Date")

    def clean(self):
        """Custom validation logic should go here"""
        pass

class ManagementReview(AbstractActivity):
    """Management review/approval"""
    approval_status = CharField(verbose_name="Status", max_length=3, choices=(
        ('APP', 'Approved'), ('REJ', 'Rejected')))
    remarks = TextField("Remarks")

    def clean(self):
        """Custom validation logic should go here"""
        pass

Step 3: Flow Definition

  • A flow is represented by collection of Activities (States/Nodes) connected using Transitions (Edges)
  • Rules are applied on transitions to allow routing between activities, provided, the condition satisfies
  • Business Process flow must be defined as FLOW under app/flow
  • As a default behavior, the Role maps OTO with django Group (developers, feel free to customize)
from activflow.leave_request.models import SampleRequest, ManagementReview
from activflow.leave_request.rules import validate_request

FLOW = {
    'sample_leave_request': {
        'name': 'Sample Request',
        'model': SampleRequest,
        'role': 'Submitter',
        'transitions': {
            'management_review': validate_request,
        }
    },
    'management_review': {
        'name': 'Management's Review',
        'model': ManagementReview,
        'role': 'Approver',
        'transitions': None
    }
}

INITIAL = 'sample_leave_request'

Step 4: Business Rules

  • Transition rules and conditions must be defined under app/rules
def validate_request(self):
    return self.reason == 'Emergency'

Step 5: Configure Field Visibility & Custom Forms (Optional)

  • Include config.py in the workflow app and define ACTIVITY_CONFIG as Nested Ordered Dictionary to have more control over what gets displayed on the UI.
  • Define for each activity model, the visibility of fields, for display on templates and forms
    • create: field will appear on activity create/initiate form
    • update: field will be available for activity update/revise operation
    • display: available for display in activity detail view
from collections import OrderedDict


ACTIVITY_CONFIG = OrderedDict([
    ('Foo', OrderedDict([
        ('Fields', OrderedDict([
            ('subject', ['create', 'update', 'display']),
            ('employee_name', ['create', 'update', 'display']),
            ('from', ['create', 'update', 'display']),
            ('to', ['create', 'update', 'display']),
            ('reason', ['create', 'update', 'display']),
            ('creation_date', ['display']),
            ('last_updated', ['display'])
        ])),
        ('Relations', OrderedDict([
            ('Itinerary', OrderedDict([
                ('destination', ['create', 'update', 'display']),
                ('date', ['create', 'update', 'display'])
            ])),
            ...
        ]))
    ])),
    ...
])

# register fields that need WYSIWYG editor

WYSIWYG_CONFIG = {
    'RequestInitiation': ['reason']
}

# register custom forms

FORM_CONFIG = {
    'RequestInitiation': 'CustomRequestForm'
}

Step 6: Access/Permission Configuration (Optional)

The core logic to restrict access is defined as AccessDeniedMixin under core/mixins which developers can customize depending on the requirements

Demo Instructions

Execute the below command to configure ActivFlow for demo purpose

python demo.py

Alternatively, launch the docker containers by simply running

docker-compose up

Submitter: john.doe/12345, Reviewer: jane.smith/12345

License

FOSSA Status

activflow's People

Contributors

dependabot[bot] avatar faxad avatar fossabot avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

activflow's Issues

is this library still maintained?

is this library still maintained (new features to be released etc)
is there any documentation to follow and understand the possible options available?
any example on how to integrate this libray to a existing django project ?

Error on_delete

Hi,

I've installed the script and I'm having the following error. Please let me know how I can fix it. Thanks,
screen shot 2018-06-07 at 7 17 27 pm

Add support for custom forms

As a developer trying to build a workflow system for my organization, I need to be able to customize the forms presented to the user. For example, a simple workflow might involve editing some HTML with a rich text editor in one activity, and then to be able to preview the rendered data on a review activity page.

I would like the ability to customize the forms presented to the user, while still being able to use the underlying engine to control the flow of activities.

Add activity names to task summary

At first glance, the UI of activflow is really nice. However, something I'm struggling with is how to visualize what step the workflow is in. For example, when I click on "view tasks" I see task IDs and the status, but no indication of what the next task or activity is.

For example, a simple workflow might be to create a paragraph of text. Maybe it's an ad for a newspaper, or a description of a product for a website. The flow might be something like edit -> proofread -> review layout -> approve -> move to production. All I see in the summary is "5 Not Started Reviewer". I have no way of knowing which task it's stuck in.

What I'd like to see instead is a column that shows the task name (eg: "Proofread" or "Layout Review") in addition to the other information. This should be a human-friendly name, so there needs to be a way to attach a name to an activity

Rich HTML support

Bryan Oakley (@boakley): I want to be able to present a rich html editor on an "edit" activity, and a rendered version of the html in a div on a "review" activity within a workflow. Does activflow support that?

Activity flow rule bypass scenario

Give:
Activity 1: Foo has value 'Sample'
Activity 1 to Activity 2 rule states that Foo cannot be Sample

Actions:

  • Foo entered as Saammpple (which satisfies the rule)
  • Activity 2 gets displayed as a valid transition from Activity 1
  • Foo changed to Sample
  • Send to Activity 2 (since transition appears)
  • Doesn't complain and sends to Activity 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.