Coverage for lino/core/boundaction.py : 78%

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
# -*- coding: UTF-8 -*- # Copyright 2009-2015 Luc Saffre # License: BSD (see file COPYING for details) .. autosummary::
"""
make_permission_handler, make_view_permission_handler)
"""An Action which is bound to an Actor. If an Actor has subclasses, each subclass "inherits" its actions.
"""
raise Exception("%s : %r is not an Action" % (actor, action))
# required = set() # required |= actor.required_roles
action.debug_permissions
if settings.DEBUG: logger.info("debug_permissions active for %r (required=%s)", self, required) else: raise Exception( "settings.DEBUG is False, but `debug_permissions` " "for %r (required=%s) is active (settings=%s)." % ( self, required, os.environ['DJANGO_SETTINGS_MODULE']))
self, action.readonly, debug_permissions, required), action) action, actor, action.readonly, debug_permissions, required, allowed_states=action.required_states), action) #~ if debug_permissions: #~ logger.info("20130424 _allow is %s",self._allow) #~ actor.actions.define(a.action_name,ba)
return self.action.get_window_size(self.actor)
"""Create a request of this action from parent request `ar`.
"""
ar = self.request_from(ses, **kw) self.action.run_from_code(ar) return ar.response
return self.action.get_button_label(self.actor, *args)
#~ def get_panel_btn_handler(self,*args): #~ return self.action.get_panel_btn_handler(self.actor,*args)
"""Checks whether this bound action has permission to run on the given database object.
This will check requirements specified on the *actor*, which by default checks those defined on the *model*, which in turn checks those defined on the *action* by calling :meth:`get_bound_action_permission`.
""" #~ if self.actor is None: return False
"""Checks whether the bound action gives permission to run.
If this is a list action, `obj` is None. If this is a row action, then `obj` is the current row. Note that this method does not (again) call any custom permission handler defined on the model.
This is done in two steps: first we check the requirements specified in `required_roles` and `required_states`, then (if these pass) we check any custom permissions defined on the action via :meth:`get_action_permission <lino.core.actions.Action.get_action_permission>`.
The order of these is important since a custom permission handler of an action with default `required_roles` can make database queries based on `ar.get_user()`, which would cause errors like :message:`Cannot assign "<lino.modlib.users.utils.AnonymousUser object at 0x7f562512f210>": "Upload.user" must be a "User" instance` when called by anonymous.
""" return False # if not self.action.get_action_permission(ar, obj, state): # return False # return self._allow(ar.get_user(), obj, state)
""" Return True if this bound action is visible for users of this profile. """ return False return False
return "<%s(%s, %r)>" % ( self.__class__.__name__, self.actor, self.action)
|