ralkan / django-rulengine

A simple rule engine for django admin
MIT License
6 stars 2 forks source link

Example Project #4

Open larsrinn opened 6 years ago

larsrinn commented 6 years ago

Is there somewhere an example project where I can inspect how django-ruleengine is implemented and what it does? I tried to grasp that by looking at the code but don't think I succeeded 100%

ralkan commented 6 years ago

Hey Lars,

Thanks for your interest and star!

I have created a simple small app to show how it works.

This is the admin page: http://178.62.246.147/admin/djrulengine/rulecontext/1/change/ Username: demo Password: demo

And you can make a request like this to test the values you put into the rulengine. http://178.62.246.147/?age=14&email=john.doe@gmail.com&country=US&bank_account=55

You'll get False with this request. Example: If you change age to be greater than 20 you'll see True on the page because the rule says that age has to be greater than 20 and email_domain has to be "gmail.com".

Here is the code of the project: https://github.com/ralkan/django-rulengine-demo

Check views.py and rules.py

Regards

larsrinn commented 6 years ago

Hey Ralkan,

thanks for the prompt answer and guiding me tot he example repo. I’ll have to take a closer look at the project because it seems like it is already halfway there, to what I’m trying to build.

How do you configure the context values for a rule?

Best

Lars

ralkan commented 6 years ago

Hello again,

Well I didn't give you permission to add and delete the context values, I've updated the demo accounts' permissions so now you can. But it's basically like this.

The non technical backoffice user adds a new context value which he/she needs in order to run some logic. When it's first added, it's implemented status is False. After the developer implemented the values and deployed the code. The first time the code is run, it'll check if the context values are implemented or not and update it to True.

Only then, can you see the context values in the rules and conditions list above.

I hope it's a bit clearer now :)

Regards,

jayvdb commented 4 years ago

https://github.com/ralkan/django-rulengine-demo should be mentioned on the readme of this repo ;-)