1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add 'add export template' link to dropdown

This commit is contained in:
jeremystretch
2021-04-05 15:13:35 -04:00
parent 3ad7622bf0
commit ae18693715
2 changed files with 9 additions and 0 deletions

View File

@ -12,5 +12,9 @@
<li><a href="?{% if url_params %}{{ url_params.urlencode }}&{% endif %}export={{ et.name }}"{% if et.description %} title="{{ et.description }}"{% endif %}>{{ et.name }}</a></li>
{% endfor %}
{% endif %}
{% if add_exporttemplate_link %}
<li class="divider"></li>
<li><a href="{{ add_exporttemplate_link }}">Add export template... </a></li>
{% endif %}
</ul>
</div>

View File

@ -82,13 +82,18 @@ def import_button(url):
@register.inclusion_tag('buttons/export.html', takes_context=True)
def export_button(context, content_type=None):
add_exporttemplate_link = None
if content_type is not None:
user = context['request'].user
export_templates = ExportTemplate.objects.restrict(user, 'view').filter(content_type=content_type)
if user.is_staff and user.has_perm('extras.add_exporttemplate'):
add_exporttemplate_link = f"{reverse('admin:extras_exporttemplate_add')}?content_type={content_type.pk}"
else:
export_templates = []
return {
'url_params': context['request'].GET,
'export_templates': export_templates,
'add_exporttemplate_link': add_exporttemplate_link,
}