[Closes #4249] Contribute back upstream menu management from IGAD #4250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR the menu management system implemented for IGAD has been generalized and simplified.
Issue: #4249
Three new models have been added in the geonode 'base' app model python module:
Two custom template tags have been implemented for the menus rendering in the templates.
The get_menu assignment tag takes the placeholder name as argument and return, as output, a dictionary like this:
{ <Menu: menu_0>: <QuerySet [<MenuItem: menu_item_0>, <MenuItem: menu_item_1>, ... ]>, ... }
It can be used everywhere (for example to perfom a dropdown menu or an accordion panel) following these steps:
1 - load the custom tag
{% load base_tags %}
2 - call the tag
{% get_menu '<placeholder_name>' %}
The render_nav_menu inclusion tag does the same job but with a predefined html rendering (geonode/base/templates/menu.html). It is prepared for being a navbar dropdown menu without any further front-end implementation needed.
It should be called inside the extra_tab block of the 'base.html' template:
{% block extra_tab %}
{% render_nav_menu '<placeholder_name>' %}
{% endblock extra_tab %}
No rendering options have been implemented yet.
No bdd test implemented.
Unittest in geonode/base/tests.py.