oioioi.base.menu¶
Attributes¶
Classes¶
Maintains a collection of values ordered by a separate key. |
|
Used to store single menu entry. |
|
Maintains a collection of menu items. |
Module Contents¶
- class oioioi.base.menu.OrderedRegistry[source]¶
Maintains a collection of values ordered by a separate key.
- items = []¶
- keys = []¶
- class oioioi.base.menu.MenuItem(name, text, url_generator, condition=None, attrs=None, order=sys.maxsize)[source]¶
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
- name¶
- text¶
- url_generator¶
- condition = None¶
- attrs = None¶
- order = 9223372036854775807¶
- class oioioi.base.menu.MenuRegistry(text=None, condition=None, show_icons=False)[source]¶
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
- text = None¶
- condition = None¶
- show_icons = False¶
- _registry = []¶
- _generators¶
- 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.pyof 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).conditionis combined with the condition taken from the view attribute of the same name (assigned for example byoioioi.base.permissions.enforce_condition()).conditionparameter 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¶