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

Enhancement - Human readable name for rules/permissions #59

Open
sergei-maertens opened this issue Jul 18, 2017 · 3 comments
Open

Enhancement - Human readable name for rules/permissions #59

sergei-maertens opened this issue Jul 18, 2017 · 3 comments

Comments

@sergei-maertens
Copy link

Hi, I've been a fan of this lib for a long time, so now I'm implementing it on a bigger scale than usual in a project and ran into an enhancement.

The context is that we want to connect some custom rules/permissions with roles, and build an UI around this. We like the format of appname:permission_name to name a permission, but this is not very readable for the end-user assigning permissions to roles. Similar to Django's permission system, we'd like to be able to provide a human readable name to the permission.

API wise, I suggest extending the API from

rules.add_perm('appname:permission_name', some_predicate)

to

rules.add_perm('appname:permission_name', some_predicate, verbose_name=_("A translatable string") )

Looking at the source code, this would make the RuleSet a bit more complex object than a simple dict, a single rule within a RuleSet would probably need to be an object itself where the verbose_name is also kept.

Thoughts? Comments? I'm willing to contribute on this with a PR!

@dfunckt
Copy link
Owner

dfunckt commented Jul 18, 2017

This sounds great to me and it's definitely desirable given Django's native perms also have this ability. I also like the API. Only question is what verbose_name should be if not specified -- should it be automatically set to the rule name or not?

PR implementing this is very welcome :)

@sergei-maertens
Copy link
Author

Defaulting to name seems sane to me, as currently that's also what's returned in repr

@jacklinke
Copy link

Resolved in #154

Would love feedback.

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

No branches or pull requests

3 participants