mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Expose regsitry in templates using existing context processor for settings
This commit is contained in:
@ -1,10 +0,0 @@
|
||||
from extras.registry import registry
|
||||
|
||||
|
||||
def plugin_menu_items(request):
|
||||
"""
|
||||
Retrieve and expose all plugin registered navigation menu items.
|
||||
"""
|
||||
return {
|
||||
'plugin_menu_items': registry['plugin_menu_items']
|
||||
}
|
@ -325,8 +325,7 @@ TEMPLATES = [
|
||||
'django.template.context_processors.media',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'utilities.context_processors.settings',
|
||||
'extras.plugins.context_processors.plugin_menu_items',
|
||||
'utilities.context_processors.settings_and_registry',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -504,7 +504,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
{% if plugin_menu_items %}
|
||||
{% if registry.plugin_menu_items %}
|
||||
{% include 'inc/plugin_menu_items.html' %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Plugins <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for section_name, menu_items in plugin_menu_items.items %}
|
||||
{% for section_name, menu_items in registry.plugin_menu_items.items %}
|
||||
<li class="dropdown-header">{{ section_name }}</li>
|
||||
{% for menu_item in menu_items %}
|
||||
<li{% if menu_item.permissions and not request.user|has_perms:menu_item.permissions %} class="disabled"{% endif %}>
|
||||
|
@ -1,10 +1,13 @@
|
||||
from django.conf import settings as django_settings
|
||||
|
||||
from extras.registry import registry
|
||||
|
||||
def settings(request):
|
||||
|
||||
def settings_and_registry(request):
|
||||
"""
|
||||
Expose Django settings in the template context. Example: {{ settings.DEBUG }}
|
||||
Expose Django settings and NetBox registry stores in the template context. Example: {{ settings.DEBUG }}
|
||||
"""
|
||||
return {
|
||||
'settings': django_settings,
|
||||
'registry': registry,
|
||||
}
|
||||
|
Reference in New Issue
Block a user