Public Codebase Reference¶
This documents the public classes and methods that may be useful to extension authors who integrate with Power Pack features.
User Roles¶
- UserRoleManager.for_user(user: User, *, local_site: LocalSite | None = None, request: HttpRequest | None = None) Sequence[UserRole]¶
Return all User Roles for a given user.
This is designed to be efficient, utilizing the memory cache backend and a local request-bound memory cache to make repeated calls inexpensive.
In an optimal case (< 10,000 user associations), this can fetch the user roles for any user in one SQL query. For larger deployments, user and role mappings will be computed as needed and cached within the lifespan of the request.
The resulting list of User Roles will be sorted in role name order.
Callers are expected to check that the user is an active member of the Local Site before calling this method.
- Parameters:
user (
django.contrib.auth.models.User) – The user for which to return User Roles.local_site (
reviewboard.site.models.LocalSite, optional) – The Local Site the User Roles should be associated with.request (
django.http.HttpRequest, optional) – The current HTTP request from the client to use for local caching.
- Returns:
The list of User Roles for the user.
- Return type:
listofrbpowerpack.roles.models.UserRole