Fields and values¶
Protected fields, the values a status action writes, and what a write must stay within.
readable_fields
¶
The fields of model user may read: every field but the protected ones they lack.
writable_fields
¶
The fields of model user may write: what they read, less what they may not edit.
path_readable
¶
Whether a lookup - region, applicant__region, -amount - reads
only fields user may read. Searching, filtering or ordering by a field
tells somebody what it holds as surely as showing it.
field_permissions
¶
{'view': ..., 'edit': ...} - the two permissions of model.name.
writable_values
¶
writable_values(user: User, model: type[Model], field: str, obj: Model | None = None) -> frozenset[Any]
The values of field user may write to obj - or to a new row.
Nothing when they may not write the field; every value for the superuser. Otherwise every value no status action claims, the value the row holds already - keeping it is no change - and the values of every action claiming them that they are allowed, from where the row stands.
require_within_scope
¶
PermissionDenied unless obj, as it is saved now, is among the rows
user reaches for action.
Asked after the row is written and inside the transaction that wrote it,
so the refusal undoes the write: a row made outside the scope create
was given in, or edited out of the scope edit was.
require_deletable
¶
PermissionDenied unless deleting rows - a row, or several - takes
only rows user may delete: those rows, and every row a cascade would
take with them.
Asked before the delete. A row deleted with another is deleted all the
same, so somebody allowed to delete a loan but no payment would otherwise
delete its payments. Every model a cascade reaches that has a delete
permission is asked for it, within its scope. What has none to ask - a
table Django makes for a many-to-many field, the library's own tables -
and what Django keeps for itself - its admin site's log, its sessions and
content types - goes as Django sends it.