Skip to content

core.patch_django ​

Overview ​

Monkey-patches Django permission codenames to use CRUD naming conventions.

get_builtin_permissions ​

Return (codename, name) pairs for the permissions Django creates for a model, with actions renamed.

Each action in opts.default_permissions is renamed through PERMISSION_NAMES_MAPPING, and a pair that two actions map to appears once. Importing this module installs it in place of Django's _get_builtin_permissions, which it copies: https://github.com/django/django/blob/f302343380c77e1eb5dab3b64dd70895a95926ca/django/contrib/auth/management/__init__.py#L22-L35

Signature ​

get_builtin_permissions(opts)

Parameters ​

NameTypeRequiredDefaultDescription
optsyes

Source ​

server/vueda/core/patch_django.py:64

get_permission_codename ​

Return the permission codename for action on the model opts describes, after renaming the action.

PERMISSION_NAMES_MAPPING renames Django's actions; by default add becomes create, change becomes update, and view becomes read. Importing this module installs it as django.contrib.auth.get_permission_codename.

Signature ​

get_permission_codename(action, opts)

Parameters ​

NameTypeRequiredDefaultDescription
actionyes
optsyes

Source ​

server/vueda/core/patch_django.py:44

Source ​

server/vueda/core/patch_django.py