mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
'safe' loading of links
This commit is contained in:
parent
36591a5f6e
commit
fa36bcdbca
@ -4,6 +4,7 @@
|
||||
"""
|
||||
from django.conf import settings as djangosettings
|
||||
from django import template
|
||||
from django.urls import reverse
|
||||
|
||||
from common.models import InvenTreeSetting
|
||||
|
||||
@ -35,3 +36,12 @@ def navigation_enabled(*args, **kwargs):
|
||||
if djangosettings.TESTING:
|
||||
return True
|
||||
return InvenTreeSetting.get_setting('ENABLE_PLUGINS_NAVIGATION')
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def safe_url(view_name, *args, **kwargs):
|
||||
""" safe lookup for urls """
|
||||
try:
|
||||
return reverse(view_name, args=args, kwargs=kwargs)
|
||||
except:
|
||||
return None
|
||||
|
@ -70,7 +70,10 @@
|
||||
</a>
|
||||
<ul class='dropdown-menu'>
|
||||
{% for nav_item in plugin.navigation %}
|
||||
<li><a href="{% url nav_item.link %}" class="dropdown-item"><span class='{{nav_item.icon}} icon-header'></span>{{nav_item.name}}</a>
|
||||
{% safe_url nav_item.link as nav_link %}
|
||||
{% if nav_link %}
|
||||
<li><a href="{{ nav_link }}" class="dropdown-item"><span class='{{nav_item.icon}} icon-header'></span>{{nav_item.name}}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user