oioioi.portals.actions

Module Contents

Functions

_register_portal_action(actions, name, condition, ...)

register_portal_action(name[, condition, menu_text, ...])

Decorator for a view, which registers it as a portal action.

register_node_action(name[, condition, menu_text, ...])

Decorator for a view, which registers it as a node action.

portal_url([portal, node, path, action])

Generates a portal action URL.

Attributes

oioioi.portals.actions.portal_actions[source]
oioioi.portals.actions.node_actions[source]
oioioi.portals.actions.DEFAULT_ACTION_NAME = show_node[source]
oioioi.portals.actions.portal_admin_menu_registry[source]
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 condition under 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 specify menu_text. If condition is specified, the action will not be visible in the admin buttons unless it is satisfied.

For portal actions, the following request attributes are set: - portal - oioioi.portals.models.Portal for which the

action 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 accessible

  • menu_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 request attributes are set: - portal - oioioi.portals.models.Portal for which the

action is called, also set in the template context

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 for portal or to

a node action for portal root

  • node - generates URL to a node action for node

  • portal and path - generates URL to a node action for a node at

    path in portal

Specifying the parameters as named arguments is advised in order to avoid confusion.

Also available as a template tag.

Parameters