دامنههای ردیف¶
دامنههایی که یک مدل دارد، و ردیفهایی که یک شخص به آنها میرسد. توضیحهای زیر از خود کد خوانده میشوند، و مثل کد به انگلیسیاند.
ScopedQuerySet
¶
Bases: QuerySet[ModelT]
A queryset that knows which of its rows each person may reach, with scopes in code.
offered_scopes
classmethod
¶
all and the scopes in code. offered_scopes(model) adds the rule scopes.
visible_to
¶
The rows user may reach for action.
A queryset that answers in a way of its own overrides this - and is
asked by visible too, so a view, the admin site and a policy get
the answer the queryset gives.
OwnedQuerySet
¶
Bases: ScopedQuerySet[ModelT]
Rows that each belong to one account, offering own.
owner_path is the lookup from a row to the account that owns it. A
subclass adds scopes of its own beside own:
scopes = {**OwnedQuerySet.scopes, 'branch': ...}.
SignedInReadQuerySet
¶
Bases: ScopedQuerySet[ModelT]
Every row, for anybody signed in, whatever they hold.
For reference data - branches, kinds of loan - that describes how the platform works rather than anything about a person. Who may change it is still the policy's to say.
visible
¶
The rows of queryset user may reach for action - for any model.
Signed out or switched off, no rows; the superuser, every row; otherwise
the union of the scopes of the action's grants. A ScopedQuerySet is
asked through its visible_to, so one that answers in a way of its own
- SignedInReadQuerySet, or a project's - answers here as well.
Asked from inside that visible_to, it answers by the grants, as
super().visible_to does: an override narrowing what the grants reach
may write either:
def visible_to(self, user, action='view'):
return visible(self, user, action).filter(archived=False)
code_scopes
¶
all and the scopes model offers in code - read with no query.
forget_grants
¶
Drop what is kept on user, after their access changed - Django's caches too.