Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Library of context processors.
4"""
6# Imports
8from .utils import user_is_allowed_to_impersonate as _user_is_allowed_to_impersonate
10# Exports
12__all__ = (
13 "user_is_allowed_to_impersonate",
14)
16# Processors
19# noinspection PyUnusedLocal
20def user_is_allowed_to_impersonate(request):
21 """Add a flag which indicates whether the current user is allowed to impersonate another user.
23 :param request: The request instance is not used.
24 :type: request: object
26 :rtype: dict
28 """
29 # The current user may already be an impersonator.
30 user = getattr(request, "impersonator", None)
31 if user is None:
32 user = request.user
34 return {
35 'user_is_allowed_to_impersonate': _user_is_allowed_to_impersonate(user)
36 }