Skip to main content

A Django centric event driven rules engine for extensible and configurable responses to changes to django models and triggers.

Project description

https://badge.fury.io/py/django-dynamic-business-rules.svg https://travis-ci.org/adamhaney/django-dynamic-business-rules.svg?branch=master https://codecov.io/gh/adamhaney/django-dynamic-business-rules/branch/master/graph/badge.svg

A Django centric event driven rules engine for extensible and configurable responses to changes to django models and triggers.

Documentation

The full documentation is at https://django-dynamic-business-rules.readthedocs.io.

Use Cases

  • Configure Rules for sending messages to users and edit them without deploying new code

  • Block spam users if they perform too many suspiscious activities during a certain time frame, allow non-programmer users to edit that time frame

  • Trigger a required password reset if a configurable set of suspiscious behaviors are encountered

Key Ideas

The goal of this project is to allow non-technical users to be able to configure behaviors of the system, similar to a commercial tool like IFFT or Zapier. Non-developer end users of this tool are not required to be programmers but they will need to be at least somewhat technical in their understanding of the system so for the remainder of the document will will refer to them as “analysts”.

Quickstart

Install Django Dynamic Business Rules:

pip install django-dynamic-business-rules

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'dynamic_business_rules.apps.DynamicBusinessRulesConfig',
    ...
)

Add Django Dynamic Business Rules’s URL patterns:

from dynamic_business_rules import urls as dynamic_business_rules_urls


urlpatterns = [
    ...
    url(r'^admin/dynamic-rules/', include(dynamic_business_rules_urls)),
    ...
]

Create a Variable class

In one of your Django apps create a variable class in a file named dynamic_rule_variables.py (this name must be used so we can introspect apps looking for implementations of variable classes)

The Variable object translates a Django signal into a set of values that non-technical users can use when creating conditional business rules. For an example Variable object see example/dynamic_rule_variables.py you’ll notice that the variable object doesn’t inherit from any object, it’s constructor receives a django signal as kwargs and then its properties evaluate the properties of that signal (in the case of the example the post_save signal’s instance is a key value).

Create an Action class

In one of your Django apps create an action class in a file named dynamic_rule_actions.py (this name must be used so we can introspect apps looking for implementations of action classes)

The action object provides methods that rule sets can “fire” if all their conditions evaluate to true.

Screenshots of Admin

Creating a New Rule

docs/img/admin_basic_rule_setup.png

Adding Conditions To Evaluate

docs/img/admin_condition_sets.png

Features

  • Allows users to implement and extend their own Variable and Action classes in a flexible way that allows you to build a business rules engine that fits the needs of your project.

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

History

0.1.0 (2019-02-08)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-dynamic-business-rules-0.1.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

django_dynamic_business_rules-0.1.2-py2.py3-none-any.whl (11.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-dynamic-business-rules-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django-dynamic-business-rules-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b0bad97c53b54240be53b172f082e07e8dcf2eaa8f17722578273f0b2d6cf023
MD5 fc3f74a5d5a44ea0d3b73ef9c7f7ee36
BLAKE2b-256 e609f2593f9643b7f1cb5bc5dd676961e953067b44ac7e8d96cf901ffe36edc9

See more details on using hashes here.

File details

Details for the file django_dynamic_business_rules-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_dynamic_business_rules-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ecb5a2de5640b3c0a4a0765b24eae084cd60a3e29249efbd5aff9fffaa522e81
MD5 482a4eeb8e2401be41794a2986e6eb15
BLAKE2b-256 88bd975725ea97001e0fcc604eb6dc2b0d792b09373fbf7348526ec8373beb2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page