oioioi.base.menu
¶
Module Contents¶
Classes¶
Maintains a collection of values ordered by a separate key. |
|
Used to store single menu entry. |
|
Maintains a collection of menu items. |
Attributes¶
- class oioioi.base.menu.OrderedRegistry[source]¶
Bases:
object
Maintains a collection of values ordered by a separate key.
- class oioioi.base.menu.MenuItem(name, text, url_generator, condition=None, attrs=None, order=sys.maxsize)[source]¶
Bases:
object
Used to store single menu entry.
- Parameters:
name – a short identifier, for example used to find a matching icon etc.
text – text to display
url_generator (fun: request → str) – generates menu link URL
order (int) – value determining the order of items in menu
condition (
oioioi.base.permissions.Condition
) – decides if the item should be shown
- class oioioi.base.menu.MenuRegistry(text=None, condition=None, show_icons=False)[source]¶
Bases:
object
Maintains a collection of menu items.
- Parameters:
text – menu name to display (if appropriate)
condition (
oioioi.base.permissions.Condition
) – decides if menu should be considered as available
- register(name, text, url_generator, condition=None, attrs=None, order=sys.maxsize)[source]¶
Registers a new menu item.
Menu items should be registered in
views.py
of Django apps.
- register_decorator(text, url_generator, condition=None, attrs=None, order=sys.maxsize)[source]¶
Decorator for a view which registers a new menu item. It accepts the same arguments as the
MenuRegistry.register()
, except forname
, which is inferred from the view function name (‘_view’ suffix is stripped).condition
is combined with the condition taken from the view attribute of the same name (assigned for example byoioioi.base.permissions.enforce_condition()
).condition
parameter influences only on visibility of menu entry but not on permission to see the page.
- oioioi.base.menu.menu_registry¶
- oioioi.base.menu.account_menu_registry¶
- oioioi.base.menu.side_pane_menus_registry¶
- oioioi.base.menu.personal_menu_registry¶
- oioioi.base.menu.navbar_links_registry¶