diff --git a/netbox/templates/circuits/circuit_list.html b/netbox/templates/circuits/circuit_list.html index 418459a15..de9922313 100644 --- a/netbox/templates/circuits/circuit_list.html +++ b/netbox/templates/circuits/circuit_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.circuits.add_circuit %} - - - Add a circuit - - - - Import circuits - + {% add_button 'circuits:circuit_add' %} + {% import_button 'circuits:circuit_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='circuits' %} + {% export_button content_type %}

{% block title %}Circuits{% endblock %}

diff --git a/netbox/templates/circuits/circuittype_list.html b/netbox/templates/circuits/circuittype_list.html index ce9cdf385..af48ecd0c 100644 --- a/netbox/templates/circuits/circuittype_list.html +++ b/netbox/templates/circuits/circuittype_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.circuits.add_circuittype %} - - - Add a circuit type - - - - Import circuit types - + {% add_button 'circuits:circuittype_add' %} + {% import_button 'circuits:circuittype_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Circuit Types{% endblock %}

diff --git a/netbox/templates/circuits/provider_list.html b/netbox/templates/circuits/provider_list.html index 9ba8bb838..cb7aab406 100644 --- a/netbox/templates/circuits/provider_list.html +++ b/netbox/templates/circuits/provider_list.html @@ -1,18 +1,13 @@ {% extends '_base.html' %} +{% load buttons %} {% block content %}
{% if perms.circuits.add_provider %} - - - Add a provider - - - - Import providers - + {% add_button 'circuits:provider_add' %} + {% import_button 'circuits:provider_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='providers' %} + {% export_button content_type %}

{% block title %}Providers{% endblock %}

diff --git a/netbox/templates/dcim/console_connections_list.html b/netbox/templates/dcim/console_connections_list.html index 57d3435e5..89eb0822d 100644 --- a/netbox/templates/dcim/console_connections_list.html +++ b/netbox/templates/dcim/console_connections_list.html @@ -1,14 +1,12 @@ {% extends '_base.html' %} +{% load buttons %} {% block content %}
{% if perms.dcim.change_consoleport %} - - - Import connections - + {% import_button 'dcim:console_connections_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='connections' %} + {% export_button content_type %}

{% block title %}Console Connections{% endblock %}

diff --git a/netbox/templates/dcim/device_list.html b/netbox/templates/dcim/device_list.html index 34b143fc5..cccdfe4c0 100644 --- a/netbox/templates/dcim/device_list.html +++ b/netbox/templates/dcim/device_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_device %} - - - Add a device - - - - Import devices - + {% add_button 'dcim:device_add' %} + {% import_button 'dcim:device_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='devices' %} + {% export_button content_type %}

{% block title %}Devices{% endblock %}

diff --git a/netbox/templates/dcim/devicerole_list.html b/netbox/templates/dcim/devicerole_list.html index 871e62806..cf58d2b1d 100644 --- a/netbox/templates/dcim/devicerole_list.html +++ b/netbox/templates/dcim/devicerole_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_devicerole %} - - - Add a device role - - - - Import device roles - + {% add_button 'dcim:devicerole_add' %} + {% import_button 'dcim:devicerole_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Device Roles{% endblock %}

diff --git a/netbox/templates/dcim/devicetype_list.html b/netbox/templates/dcim/devicetype_list.html index 69807fcff..e0f365786 100644 --- a/netbox/templates/dcim/devicetype_list.html +++ b/netbox/templates/dcim/devicetype_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_devicetype %} - - - Add a device type - - - - Import device types - + {% add_button 'dcim:devicetype_add' %} + {% import_button 'dcim:devicetype_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='device types' %} + {% export_button content_type %}

{% block title %}Device Types{% endblock %}

diff --git a/netbox/templates/dcim/interface_connections_list.html b/netbox/templates/dcim/interface_connections_list.html index a7355a449..950eb2f0b 100644 --- a/netbox/templates/dcim/interface_connections_list.html +++ b/netbox/templates/dcim/interface_connections_list.html @@ -1,14 +1,12 @@ {% extends '_base.html' %} +{% load buttons %} {% block content %}
{% if perms.dcim.add_interfaceconnection %} - - - Import connections - + {% import_button 'dcim:interface_connections_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='connections' %} + {% export_button content_type %}

{% block title %}Interface Connections{% endblock %}

diff --git a/netbox/templates/dcim/inventoryitem_list.html b/netbox/templates/dcim/inventoryitem_list.html index 612534d98..5662b51d9 100644 --- a/netbox/templates/dcim/inventoryitem_list.html +++ b/netbox/templates/dcim/inventoryitem_list.html @@ -1,15 +1,13 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_devicetype %} - - - Import inventory items - + {% import_button 'dcim:inventoryitem_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='inventory items' %} + {% export_button content_type %}

{% block title %}Inventory Items{% endblock %}

diff --git a/netbox/templates/dcim/manufacturer_list.html b/netbox/templates/dcim/manufacturer_list.html index ff6025af5..0ca9c40b3 100644 --- a/netbox/templates/dcim/manufacturer_list.html +++ b/netbox/templates/dcim/manufacturer_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_manufacturer %} - - - Add a manufacturer - - - - Import manufacturers - + {% add_button 'dcim:manufacturer_add' %} + {% import_button 'dcim:manufacturer_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='manufacturers' %} + {% export_button content_type %}

{% block title %}Manufacturers{% endblock %}

diff --git a/netbox/templates/dcim/platform_list.html b/netbox/templates/dcim/platform_list.html index dc8d43660..66dce9252 100644 --- a/netbox/templates/dcim/platform_list.html +++ b/netbox/templates/dcim/platform_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_platform %} - - - Add a platform - - - - Import platforms - + {% add_button 'dcim:platform_add' %} + {% import_button 'dcim:platform_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Platforms{% endblock %}

diff --git a/netbox/templates/dcim/power_connections_list.html b/netbox/templates/dcim/power_connections_list.html index 50e983bec..4e351eb6a 100644 --- a/netbox/templates/dcim/power_connections_list.html +++ b/netbox/templates/dcim/power_connections_list.html @@ -1,14 +1,12 @@ {% extends '_base.html' %} +{% load buttons %} {% block content %}
{% if perms.dcim.change_powerport %} - - - Import connections - + {% import_button 'dcim:power_connections_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='connections' %} + {% export_button content_type %}

{% block title %}Power Connections{% endblock %}

diff --git a/netbox/templates/dcim/rack_list.html b/netbox/templates/dcim/rack_list.html index 88b5a2f9d..eb00800ec 100644 --- a/netbox/templates/dcim/rack_list.html +++ b/netbox/templates/dcim/rack_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_rack %} - - - Add a rack - - - - Import racks - + {% add_button 'dcim:rack_add' %} + {% import_button 'dcim:rack_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='racks' %} + {% export_button content_type %}

{% block title %}Racks{% endblock %}

diff --git a/netbox/templates/dcim/rackgroup_list.html b/netbox/templates/dcim/rackgroup_list.html index d5853f11c..51989db0f 100644 --- a/netbox/templates/dcim/rackgroup_list.html +++ b/netbox/templates/dcim/rackgroup_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_rackgroup %} - - - Add a rack group - - - - Import rack groups - + {% add_button 'dcim:rackgroup_add' %} + {% import_button 'dcim:rackgroup_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='rack groups' %} + {% export_button content_type %}

{% block title %}Rack Groups{% endblock %}

diff --git a/netbox/templates/dcim/region_list.html b/netbox/templates/dcim/region_list.html index 4d61b4acb..d6b9f1c5a 100644 --- a/netbox/templates/dcim/region_list.html +++ b/netbox/templates/dcim/region_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.dcim.add_region %} - - - Add a region - - - - Import regions - + {% add_button 'dcim:region_add' %} + {% import_button 'dcim:region_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='regions' %} + {% export_button content_type %}

{% block title %}Regions{% endblock %}

diff --git a/netbox/templates/dcim/site_list.html b/netbox/templates/dcim/site_list.html index 6d3e2f7f7..7baa76dad 100644 --- a/netbox/templates/dcim/site_list.html +++ b/netbox/templates/dcim/site_list.html @@ -1,18 +1,13 @@ {% extends '_base.html' %} +{% load buttons %} {% block content %}
{% if perms.dcim.add_site %} - - - Add a site - - - - Import sites - + {% add_button 'dcim:site_add' %} + {% import_button 'dcim:site_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='sites' %} + {% export_button content_type %}

{% block title %}Sites{% endblock %}

diff --git a/netbox/templates/inc/export_button.html b/netbox/templates/inc/export_button.html deleted file mode 100644 index 8851fe1f7..000000000 --- a/netbox/templates/inc/export_button.html +++ /dev/null @@ -1,20 +0,0 @@ -{% if export_templates %} -
- - -
-{% else %} - - - Export {{ obj_type }} - -{% endif %} diff --git a/netbox/templates/ipam/aggregate_list.html b/netbox/templates/ipam/aggregate_list.html index df8e4772e..7b15479f6 100644 --- a/netbox/templates/ipam/aggregate_list.html +++ b/netbox/templates/ipam/aggregate_list.html @@ -1,20 +1,15 @@ {% extends '_base.html' %} +{% load buttons %} {% load humanize %} {% load helpers %} {% block content %}
{% if perms.ipam.add_aggregate %} - - - Add an aggregate - - - - Import aggregates - + {% add_button 'ipam:aggregate_add' %} + {% import_button 'ipam:aggregate_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='aggregates' %} + {% export_button content_type %}

{% block title %}Aggregates{% endblock %}

diff --git a/netbox/templates/ipam/ipaddress_list.html b/netbox/templates/ipam/ipaddress_list.html index 2d273145d..9e378de54 100644 --- a/netbox/templates/ipam/ipaddress_list.html +++ b/netbox/templates/ipam/ipaddress_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.ipam.add_ipaddress %} - - - Add an IP - - - - Import IPs - - {% endif %} - {% include 'inc/export_button.html' with obj_type='IPs' %} + {% add_button 'ipam:ipaddress_add' %} + {% import_button 'ipam:ipaddress_import' %} + {% endif %} + {% export_button content_type %}

{% block title %}IP Addresses{% endblock %}

diff --git a/netbox/templates/ipam/prefix_list.html b/netbox/templates/ipam/prefix_list.html index 4747731f8..8e6d28d49 100644 --- a/netbox/templates/ipam/prefix_list.html +++ b/netbox/templates/ipam/prefix_list.html @@ -1,4 +1,5 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% load form_helpers %} @@ -9,16 +10,10 @@ Expand
{% if perms.ipam.add_prefix %} - - - Add a prefix - - - - Import prefixes - - {% endif %} - {% include 'inc/export_button.html' with obj_type='prefixes' %} + {% add_button 'ipam:prefix_add' %} + {% import_button 'ipam:prefix_import' %} + {% endif %} + {% export_button content_type %}

{% block title %}Prefixes{% endblock %}

diff --git a/netbox/templates/ipam/rir_list.html b/netbox/templates/ipam/rir_list.html index bd2a30c2a..40a21fc25 100644 --- a/netbox/templates/ipam/rir_list.html +++ b/netbox/templates/ipam/rir_list.html @@ -1,4 +1,5 @@ {% extends '_base.html' %} +{% load buttons %} {% load humanize %} {% load helpers %} @@ -16,15 +17,10 @@ {% endif %} {% if perms.ipam.add_rir %} - - - Add a RIR - - - - Import RIRs - + {% add_button 'ipam:rir_add' %} + {% import_button 'ipam:rir_import' %} {% endif %} + {% export_button content_type %}

{% block title %}RIRs{% endblock %}

diff --git a/netbox/templates/ipam/role_list.html b/netbox/templates/ipam/role_list.html index 54b0a8925..bc493e15b 100644 --- a/netbox/templates/ipam/role_list.html +++ b/netbox/templates/ipam/role_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.ipam.add_role %} - - - Add a role - - - - Import roles - + {% add_button 'ipam:role_add' %} + {% import_button 'ipam:role_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Prefix/VLAN Roles{% endblock %}

diff --git a/netbox/templates/ipam/vlan_list.html b/netbox/templates/ipam/vlan_list.html index b5db84e52..29fc6a79d 100644 --- a/netbox/templates/ipam/vlan_list.html +++ b/netbox/templates/ipam/vlan_list.html @@ -1,20 +1,15 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% load form_helpers %} {% block content %}
{% if perms.ipam.add_vlan %} - - - Add a VLAN - - - - Import VLANs - - {% endif %} - {% include 'inc/export_button.html' with obj_type='VLANs' %} + {% add_button 'ipam:vlan_add' %} + {% import_button 'ipam:vlan_import' %} + {% endif %} + {% export_button content_type %}

{% block title %}VLANs{% endblock %}

diff --git a/netbox/templates/ipam/vlangroup_list.html b/netbox/templates/ipam/vlangroup_list.html index 77d8e9b30..6eb63afdc 100644 --- a/netbox/templates/ipam/vlangroup_list.html +++ b/netbox/templates/ipam/vlangroup_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.ipam.add_vlangroup %} - - - Add a VLAN group - - - - Import VLAN groups - + {% add_button 'ipam:vlangroup_add' %} + {% import_button 'ipam:vlangroup_import' %} {% endif %} + {% export_button content_type %}

{% block title %}VLAN Groups{% endblock %}

diff --git a/netbox/templates/ipam/vrf_list.html b/netbox/templates/ipam/vrf_list.html index 029426a14..479947554 100644 --- a/netbox/templates/ipam/vrf_list.html +++ b/netbox/templates/ipam/vrf_list.html @@ -5,16 +5,10 @@ {% block content %}
{% if perms.ipam.add_vrf %} - - - Add a VRF - - - - Import VRFs - - {% endif %} - {% include 'inc/export_button.html' with obj_type='VRFs' %} + {% add_button 'ipam:vrf_add' %} + {% import_button 'ipam:vrf_import' %} + {% endif %} + {% export_button content_type %}

{% block title %}VRFs{% endblock %}

diff --git a/netbox/templates/secrets/secret_list.html b/netbox/templates/secrets/secret_list.html index 5293b5a6d..4e2aa9cb9 100644 --- a/netbox/templates/secrets/secret_list.html +++ b/netbox/templates/secrets/secret_list.html @@ -1,13 +1,11 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.secrets.add_secret %} - - - Import secrets - + {% import_button 'secrets:secret_import' %} {% endif %}

{% block title %}Secrets{% endblock %}

diff --git a/netbox/templates/secrets/secretrole_list.html b/netbox/templates/secrets/secretrole_list.html index ccaa20730..c76c8f748 100644 --- a/netbox/templates/secrets/secretrole_list.html +++ b/netbox/templates/secrets/secretrole_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
- {% if perms.dcim.add_devicerole %} - - - Add a secret role - - - - Import secret roles - + {% if perms.secrets.add_secretrole %} + {% add_button 'secrets:secretrole_add' %} + {% import_button 'secrets:secretrole_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Secret Roles{% endblock %}

diff --git a/netbox/templates/tenancy/tenant_list.html b/netbox/templates/tenancy/tenant_list.html index afc1a154f..c2181f1b8 100644 --- a/netbox/templates/tenancy/tenant_list.html +++ b/netbox/templates/tenancy/tenant_list.html @@ -1,19 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.tenancy.add_tenant %} - - - Add a tenant - - - - Import tenants - + {% add_button 'tenancy:tenant_add' %} + {% import_button 'tenancy:tenant_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='tenants' %} + {% export_button content_type %}

{% block title %}Tenants{% endblock %}

diff --git a/netbox/templates/tenancy/tenantgroup_list.html b/netbox/templates/tenancy/tenantgroup_list.html index 3bffb5c6b..26bbb86bd 100644 --- a/netbox/templates/tenancy/tenantgroup_list.html +++ b/netbox/templates/tenancy/tenantgroup_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.tenancy.add_tenantgroup %} - - - Add a tenant group - - - - Import tenant groups - + {% add_button 'tenancy:tenantgroup_add' %} + {% import_button 'tenancy:tenantgroup_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Tenant Groups{% endblock %}

diff --git a/netbox/templates/virtualization/cluster_list.html b/netbox/templates/virtualization/cluster_list.html index dad7a9e49..08f62e6ba 100644 --- a/netbox/templates/virtualization/cluster_list.html +++ b/netbox/templates/virtualization/cluster_list.html @@ -1,18 +1,13 @@ {% extends '_base.html' %} +{% load buttons %} {% block content %}
{% if perms.virtualization.add_cluster %} - - - Add a cluster - - - - Import clusters - + {% add_button 'virtualization:cluster_add' %} + {% import_button 'virtualization:cluster_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='clusters' %} + {% export_button content_type %}

{% block title %}Clusters{% endblock %}

diff --git a/netbox/templates/virtualization/clustergroup_list.html b/netbox/templates/virtualization/clustergroup_list.html index 6d28400c0..a5d042f65 100644 --- a/netbox/templates/virtualization/clustergroup_list.html +++ b/netbox/templates/virtualization/clustergroup_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.virtualization.add_clustergroup %} - - - Add a cluster group - - - - Import cluster groups - + {% add_button 'virtualization:clustergroup_add' %} + {% import_button 'virtualization:clustergroup_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Cluster Groups{% endblock %}

diff --git a/netbox/templates/virtualization/clustertype_list.html b/netbox/templates/virtualization/clustertype_list.html index 7d905ba06..b05ae9afe 100644 --- a/netbox/templates/virtualization/clustertype_list.html +++ b/netbox/templates/virtualization/clustertype_list.html @@ -1,18 +1,14 @@ {% extends '_base.html' %} +{% load buttons %} {% load helpers %} {% block content %}
{% if perms.virtualization.add_clustertype %} - - - Add a cluster type - - - - Import cluster types - + {% add_button 'virtualization:clustertype_add' %} + {% import_button 'virtualization:clustertype_import' %} {% endif %} + {% export_button content_type %}

{% block title %}Cluster Types{% endblock %}

diff --git a/netbox/templates/virtualization/virtualmachine_list.html b/netbox/templates/virtualization/virtualmachine_list.html index a771dfbd9..30ed76dae 100644 --- a/netbox/templates/virtualization/virtualmachine_list.html +++ b/netbox/templates/virtualization/virtualmachine_list.html @@ -1,18 +1,13 @@ {% extends '_base.html' %} +{% load buttons %} {% block content %}
{% if perms.virtualization.add_virtualmachine %} - - - Add a virtual machine - - - - Import virtual machines - + {% add_button 'virtualization:virtualmachine_add' %} + {% import_button 'virtualization:virtualmachine_import' %} {% endif %} - {% include 'inc/export_button.html' with obj_type='virtual machines' %} + {% export_button content_type %}

{% block title %}Virtual Machines{% endblock %}

diff --git a/netbox/utilities/templates/buttons/add.html b/netbox/utilities/templates/buttons/add.html new file mode 100644 index 000000000..a5278ae12 --- /dev/null +++ b/netbox/utilities/templates/buttons/add.html @@ -0,0 +1,3 @@ + + Add + diff --git a/netbox/utilities/templates/buttons/export.html b/netbox/utilities/templates/buttons/export.html new file mode 100644 index 000000000..ee76dae6c --- /dev/null +++ b/netbox/utilities/templates/buttons/export.html @@ -0,0 +1,19 @@ +{% if export_templates %} +
+ + +
+{% else %} + + Export + +{% endif %} \ No newline at end of file diff --git a/netbox/utilities/templates/buttons/import.html b/netbox/utilities/templates/buttons/import.html new file mode 100644 index 000000000..67be77871 --- /dev/null +++ b/netbox/utilities/templates/buttons/import.html @@ -0,0 +1,3 @@ + + Import + diff --git a/netbox/utilities/templatetags/buttons.py b/netbox/utilities/templatetags/buttons.py new file mode 100644 index 000000000..3090f4538 --- /dev/null +++ b/netbox/utilities/templatetags/buttons.py @@ -0,0 +1,26 @@ +from __future__ import unicode_literals + +from django import template + +from extras.models import ExportTemplate + +register = template.Library() + + +@register.inclusion_tag('buttons/add.html') +def add_button(url): + return {'add_url': url} + + +@register.inclusion_tag('buttons/import.html') +def import_button(url): + return {'import_url': url} + + +@register.inclusion_tag('buttons/export.html', takes_context=True) +def export_button(context, content_type=None): + export_templates = ExportTemplate.objects.filter(content_type=content_type) + return { + 'url_params': context['request'].GET, + 'export_templates': export_templates, + } diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py index 917cf3002..7e1a34e19 100644 --- a/netbox/utilities/views.py +++ b/netbox/utilities/views.py @@ -79,7 +79,7 @@ class ObjectListView(View): def get(self, request): model = self.queryset.model - object_ct = ContentType.objects.get_for_model(model) + content_type = ContentType.objects.get_for_model(model) if self.filter: self.queryset = self.filter(request.GET, self.queryset).qs @@ -92,7 +92,7 @@ class ObjectListView(View): # Check for export template rendering if request.GET.get('export'): - et = get_object_or_404(ExportTemplate, content_type=object_ct, name=request.GET.get('export')) + et = get_object_or_404(ExportTemplate, content_type=content_type, name=request.GET.get('export')) queryset = CustomFieldQueryset(self.queryset, custom_fields) if custom_fields else self.queryset try: return et.render_to_response(queryset) @@ -125,10 +125,10 @@ class ObjectListView(View): RequestConfig(request, paginate).configure(table) context = { + 'content_type': content_type, 'table': table, 'permissions': permissions, 'filter_form': self.filter_form(request.GET, label_suffix='') if self.filter_form else None, - 'export_templates': ExportTemplate.objects.filter(content_type=object_ct), } context.update(self.extra_context())