Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow OR operation for the condition statement #39

Closed
tanonl opened this issue Sep 28, 2020 · 3 comments
Closed

Allow OR operation for the condition statement #39

tanonl opened this issue Sep 28, 2020 · 3 comments

Comments

@tanonl
Copy link
Contributor

tanonl commented Sep 28, 2020

I love this package. It is exactly what I needed. Simple and Clear

I have maybe one suggestion. Currently, the condition statement is basically a AND operation, all conditions in the list need to be True. It would good also to be able to have an OR operation.
e.g. "condition" : ["balance_is_positive", "account_is_blocked | is_manager"]
e.g. "condition" : "balance_is_positive & (is_manager | account_is_blocked)"

@rsinger86
Copy link
Owner

clever, I like it! would you be interested in submitting a pull request?

@tanonl
Copy link
Contributor Author

tanonl commented Oct 13, 2020

I created a pull request for that.
The easiest way I found is to use pyparsing.py to parse the expression.
I based myself on this example

@rsinger86
Copy link
Owner

Thanks. I finally got this merged in. I added a short note to the docs here:
https://rsinger86.github.io/drf-access-policy/object_level_permissions/

Glad to refine/expand as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants