Contrib module
Table of Contents
Users
Admin
Predicates
- iam.contrib.predicates.is_any_helper(check_role_conf)
Check if any of the profiles this user belongs to pass check_role_conf(role_conf)
- Parameters
check_role_conf – Function that returns true if a particular role_conf passes a certain criteria.
- Returns
A function that receives a user and returns if they belong to the roles we want qualified by check_role_conf.
- iam.contrib.predicates.p_system = <Predicate:always_deny object>
Permission predicate for actions that can only be done by the system. Same as
rules.always_deny
. Used for semantic and readability reasons overrules.always_deny
.- Example:
>>> class MyModel(RulesModel): ... class Meta: ... rules_permissions = {'add': p_system} # Only the system may create new MyModel instances.
Permissions
- class iam.contrib.perms.Perms
A utility class with common rules_permissions (from rules.RulesModel interface) values.
- Example:
>>> class MyModel(RulesModel): ... class Meta: ... rules_permissions = Perms.all_is_staff
Utilities
- iam.contrib.utils.get_profile_cls_verbose_name_plural(cls_name: Optional[str] = None, verbose: Optional[str] = None)
Create a verbose_name_plural for a profile model that includes a 👤 emoji. Use this class to make your profile classes stand out in the admin.
- Parameters
cls_name – If this value is passed, it uses the class name to build verbose_name_plural.
verbose – If this value is passed, it uses this value to build the verbose_name_plural.
- Returns
A string to pass to model._meta.verbose_name_plural.