Package expedient :: Package common :: Package permissions :: Module views
[hide private]
[frames] | no frames]

Module views

source code

Created on Jun 6, 2010


Author: jnaous

Functions [hide private]
 
reraise_permission_denied(request, perm_name=None, target_ct_id=None, target_id=None, permittee_ct_id=None, permittee_id=None)
Raises a PermissionDenied exception for the given parameters.
source code
 
redirect_permissions_request(request, perm_name=None, target_ct_id=None, target_id=None, permittee_ct_id=None, permittee_id=None)
Gets the target and permittee objects and passes them along with the ExpedientPermission object named by perm_name to the view that's used by the permission.
source code
 
request_permission(always_redirect_to=None, permission_owners_func=None, extra_context={}, template='permissions/get_permission.html')
Get a generic view to use for creating PermissionRequests.
source code
Variables [hide private]
  logger = logging.getLogger("permissions.views")
  __package__ = 'expedient.common.permissions'
Function Details [hide private]

request_permission(always_redirect_to=None, permission_owners_func=None, extra_context={}, template='permissions/get_permission.html')

source code 

Get a generic view to use for creating PermissionRequests. Because of the way the permissions app stores views, this function will need to be wrapped in another function. For example:

   def req_perm_wrapper(*args, **kwargs):
       return request_permission()(*args, **kwargs)

The view's template context will have:

The form will show all users that can delegate the requested permission by default. To change the shown set, specify permission_owners_func which should return the set to show.

Parameters:
  • always_redirect_to - path to redirect to after the permission request is saved. If None, then use the redirect_to parameter given to the view from the permission redirection. Default None. This can also be a callable that takes the request as argument.
  • permission_owners_func - A callable with the following signature:
           permission_owners_func(request, obj_permission, permittee)
           
       Where C{request} is the request object passed to the view,
       C{obj_permission} is the requested L{ObjectPermission} instance, and
       C{permittee} is the object that will own the permission. The
       function should return a C{django.contrib.auth.models.User} C{QuerySet}.
    
  • extra_context - A dictionary of values to add to the template context. By default, this is an empty dictionary. If a value in the dictionary is callable, the generic view will call it just before rendering the template.
  • template - Path of the template to use. By default, this is "permissions/get_permission.html".