oioioi.portals.actions¶
Module Contents¶
Functions¶
|
|
|
Decorator for a view, which registers it as a portal action. |
|
Decorator for a view, which registers it as a node action. |
|
Generates a portal action URL. |
Attributes¶
- oioioi.portals.actions._register_portal_action(actions, name, condition, menu_text, menu_url_generator, menu_order)[source]¶
- oioioi.portals.actions.register_portal_action(name, condition=None, menu_text=None, menu_order=sys.maxsize)[source]¶
Decorator for a view, which registers it as a portal action.
A portal action is a view which operates on a portal. After registration, it is accessible at URL /users/username/portal/?action=``name``. You can specify a
conditionunder which the action can be accessed. The action can also be added to the portal admin menu. In order to do that, you have to specifymenu_text. Ifconditionis specified, the action will not be visible in the admin buttons unless it is satisfied.For portal actions, the following
requestattributes are set: -portal-oioioi.portals.models.Portalfor which theaction is called, also set in the template context
action- action name
- Parameters
name – action name, shown in the URL
condition (
oioioi.base.permissions.Condition) – decides if the action is accessiblemenu_text – text to display in the portal admin menu
menu_order – value determining the order of items in the portal admin menu
- oioioi.portals.actions.register_node_action(name, condition=None, menu_text=None, menu_order=sys.maxsize)[source]¶
Decorator for a view, which registers it as a node action.
A node action is a view which operates on a portal node. After registration, it is accessible at URL /users/username/portal/path/to/node?action=``name``.
For node actions, the following
requestattributes are set: -portal-oioioi.portals.models.Portalfor which theaction is called, also set in the template context
current_node-oioioi.portals.models.Nodefor which theaction is called, also set in the template context
action- action name
Parameters are the same as for
oioioi.portals.actions.register_portal_action().
- oioioi.portals.actions.portal_url(portal=None, node=None, path=None, action=DEFAULT_ACTION_NAME)[source]¶
Generates a portal action URL.
This is an analog of
django.urls.reverse()for portal actions. Three parameter sets are possible: -portal- generates URL to a portal action forportalor toa node action for
portalrootnode- generates URL to a node action fornodeportalandpath- generates URL to a node action for a node atpathinportal
Specifying the parameters as named arguments is advised in order to avoid confusion.
Also available as a template tag.
- Parameters
portal (
oioioi.portals.models.Portal) – portal for which URL is generatednode (
oioioi.portals.models.Node) – portal node for which URL is generatedpath – path to the node for which URL is generated
action – name of the action to which URL is generated