From d5d87e0fdd4a297cea5385432054d54f649cd5a4 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 19 Nov 2020 12:24:52 -0500 Subject: [PATCH] Update templates to use "object" context var --- netbox/circuits/views.py | 4 +- netbox/dcim/views.py | 6 +- netbox/extras/views.py | 4 +- netbox/ipam/views.py | 20 +-- netbox/templates/circuits/circuit.html | 60 ++++----- .../circuits/inc/circuit_termination.html | 14 +-- netbox/templates/circuits/provider.html | 52 ++++---- netbox/templates/dcim/devicetype.html | 20 +-- netbox/templates/dcim/inc/rack_elevation.html | 4 +- netbox/templates/dcim/rack.html | 108 ++++++++-------- netbox/templates/dcim/site.html | 110 ++++++++-------- netbox/templates/dcim/virtualchassis.html | 42 +++---- netbox/templates/extras/configcontext.html | 56 ++++----- netbox/templates/extras/objectchange.html | 40 +++--- netbox/templates/extras/tag.html | 20 +-- netbox/templates/ipam/aggregate.html | 50 ++++---- netbox/templates/ipam/ipaddress.html | 80 ++++++------ netbox/templates/ipam/prefix.html | 86 ++++++------- netbox/templates/ipam/routetarget.html | 36 +++--- netbox/templates/ipam/vlan.html | 76 +++++------ netbox/templates/ipam/vrf.html | 42 +++---- netbox/templates/tenancy/tenant.html | 66 +++++----- netbox/templates/virtualization/cluster.html | 62 ++++----- .../virtualization/virtualmachine.html | 118 +++++++++--------- .../templates/virtualization/vminterface.html | 38 +++--- netbox/tenancy/views.py | 2 +- netbox/virtualization/views.py | 6 +- 27 files changed, 611 insertions(+), 611 deletions(-) diff --git a/netbox/circuits/views.py b/netbox/circuits/views.py index 2edb5a78e..67869f007 100644 --- a/netbox/circuits/views.py +++ b/netbox/circuits/views.py @@ -45,7 +45,7 @@ class ProviderView(generic.ObjectView): RequestConfig(request, paginate).configure(circuits_table) return render(request, 'circuits/provider.html', { - 'provider': provider, + 'object': provider, 'circuits_table': circuits_table, }) @@ -144,7 +144,7 @@ class CircuitView(generic.ObjectView): termination_z.ip_addresses = termination_z.connected_endpoint.ip_addresses.restrict(request.user, 'view') return render(request, 'circuits/circuit.html', { - 'circuit': circuit, + 'object': circuit, 'termination_a': termination_a, 'termination_z': termination_z, }) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index f8fb415ea..879f1a7cf 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -172,7 +172,7 @@ class SiteView(generic.ObjectView): ).restrict(request.user, 'view').filter(site=site) return render(request, 'dcim/site.html', { - 'site': site, + 'object': site, 'stats': stats, 'rack_groups': rack_groups, }) @@ -360,7 +360,7 @@ class RackView(generic.ObjectView): power_feeds = PowerFeed.objects.restrict(request.user, 'view').filter(rack=rack).prefetch_related('power_panel') return render(request, 'dcim/rack.html', { - 'rack': rack, + 'object': rack, 'device_count': Device.objects.restrict(request.user, 'view').filter(rack=rack).count(), 'reservations': reservations, 'power_feeds': power_feeds, @@ -2335,7 +2335,7 @@ class VirtualChassisView(generic.ObjectView): members = Device.objects.restrict(request.user).filter(virtual_chassis=virtualchassis) return render(request, 'dcim/virtualchassis.html', { - 'virtualchassis': virtualchassis, + 'object': virtualchassis, 'members': members, }) diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 38b3f5148..37a3ad210 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -109,7 +109,7 @@ class ConfigContextView(generic.ObjectView): format = 'json' return render(request, 'extras/configcontext.html', { - 'configcontext': configcontext, + 'object': configcontext, 'format': format, }) @@ -215,7 +215,7 @@ class ObjectChangeView(generic.ObjectView): diff_added = diff_removed = objectchange.object_data return render(request, 'extras/objectchange.html', { - 'objectchange': objectchange, + 'object': objectchange, 'diff_added': diff_added, 'diff_removed': diff_removed, 'next_change': next_change, diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 2ee6979df..40d8a5207 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -43,7 +43,7 @@ class VRFView(generic.ObjectView): ) return render(request, 'ipam/vrf.html', { - 'vrf': vrf, + 'object': vrf, 'prefix_count': prefix_count, 'import_targets_table': import_targets_table, 'export_targets_table': export_targets_table, @@ -106,7 +106,7 @@ class RouteTargetView(generic.ObjectView): ) return render(request, 'ipam/routetarget.html', { - 'routetarget': routetarget, + 'object': routetarget, 'importing_vrfs_table': importing_vrfs_table, 'exporting_vrfs_table': exporting_vrfs_table, }) @@ -241,7 +241,7 @@ class AggregateView(generic.ObjectView): } return render(request, 'ipam/aggregate.html', { - 'aggregate': aggregate, + 'object': aggregate, 'prefix_table': prefix_table, 'permissions': permissions, 'show_available': request.GET.get('show_available', 'true') == 'true', @@ -358,7 +358,7 @@ class PrefixView(generic.ObjectView): duplicate_prefix_table.exclude = ('vrf',) return render(request, 'ipam/prefix.html', { - 'prefix': prefix, + 'object': prefix, 'aggregate': aggregate, 'parent_prefix_table': parent_prefix_table, 'duplicate_prefix_table': duplicate_prefix_table, @@ -399,7 +399,7 @@ class PrefixPrefixesView(generic.ObjectView): } return render(request, 'ipam/prefix_prefixes.html', { - 'prefix': prefix, + 'object': prefix, 'first_available_prefix': prefix.get_first_available_prefix(), 'prefix_table': prefix_table, 'permissions': permissions, @@ -443,7 +443,7 @@ class PrefixIPAddressesView(generic.ObjectView): } return render(request, 'ipam/prefix_ipaddresses.html', { - 'prefix': prefix, + 'object': prefix, 'first_available_ip': prefix.get_first_available_ip(), 'ip_table': ip_table, 'permissions': permissions, @@ -539,7 +539,7 @@ class IPAddressView(generic.ObjectView): RequestConfig(request, paginate).configure(related_ips_table) return render(request, 'ipam/ipaddress.html', { - 'ipaddress': ipaddress, + 'object': ipaddress, 'parent_prefixes_table': parent_prefixes_table, 'duplicate_ips_table': duplicate_ips_table, 'more_duplicate_ips': duplicate_ips.count() > 10, @@ -739,7 +739,7 @@ class VLANView(generic.ObjectView): prefix_table.exclude = ('vlan',) return render(request, 'ipam/vlan.html', { - 'vlan': vlan, + 'object': vlan, 'prefix_table': prefix_table, }) @@ -759,7 +759,7 @@ class VLANInterfacesView(generic.ObjectView): RequestConfig(request, paginate).configure(members_table) return render(request, 'ipam/vlan_interfaces.html', { - 'vlan': vlan, + 'object': vlan, 'members_table': members_table, 'active_tab': 'interfaces', }) @@ -780,7 +780,7 @@ class VLANVMInterfacesView(generic.ObjectView): RequestConfig(request, paginate).configure(members_table) return render(request, 'ipam/vlan_vminterfaces.html', { - 'vlan': vlan, + 'object': vlan, 'members_table': members_table, 'active_tab': 'vminterfaces', }) diff --git a/netbox/templates/circuits/circuit.html b/netbox/templates/circuits/circuit.html index dde053ee0..0948610c8 100644 --- a/netbox/templates/circuits/circuit.html +++ b/netbox/templates/circuits/circuit.html @@ -4,15 +4,15 @@ {% load helpers %} {% load plugins %} -{% block title %}{{ circuit }}{% endblock %} +{% block title %}{{ object }}{% endblock %} {% block header %}
@@ -29,29 +29,29 @@
- {% plugin_buttons circuit %} + {% plugin_buttons object %} {% if perms.circuits.add_circuit %} - {% clone_button circuit %} + {% clone_button object %} {% endif %} {% if perms.circuits.change_circuit %} - {% edit_button circuit %} + {% edit_button object %} {% endif %} {% if perms.circuits.delete_circuit %} - {% delete_button circuit %} + {% delete_button object %} {% endif %}
-

{{ circuit }}

- {% include 'inc/created_updated.html' with obj=circuit %} +

{{ object }}

+ {% include 'inc/created_updated.html' with obj=object %}
- {% custom_links circuit %} + {% custom_links object %}
@@ -68,31 +68,31 @@ Status - {{ circuit.get_status_display }} + {{ object.get_status_display }} Provider - {{ circuit.provider }} + {{ object.provider }} Circuit ID - {{ circuit.cid }} + {{ object.cid }} Type - {{ circuit.type }} + {{ object.type }} Tenant - {% if circuit.tenant %} - {% if circuit.tenant.group %} - {{ circuit.tenant.group }} / + {% if object.tenant %} + {% if object.tenant.group %} + {{ object.tenant.group }} / {% endif %} - {{ circuit.tenant }} + {{ object.tenant }} {% else %} None {% endif %} @@ -100,43 +100,43 @@ Install Date - {{ circuit.install_date|placeholder }} + {{ object.install_date|placeholder }} Commit Rate - {{ circuit.commit_rate|humanize_speed|placeholder }} + {{ object.commit_rate|humanize_speed|placeholder }} Description - {{ circuit.description|placeholder }} + {{ object.description|placeholder }} - {% include 'inc/custom_fields_panel.html' with obj=circuit %} - {% include 'extras/inc/tags_panel.html' with tags=circuit.tags.all url='circuits:circuit_list' %} + {% include 'inc/custom_fields_panel.html' with obj=object %} + {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:circuit_list' %}
Comments
- {% if circuit.comments %} - {{ circuit.comments|render_markdown }} + {% if object.comments %} + {{ object.comments|render_markdown }} {% else %} None {% endif %}
- {% plugin_left_page circuit %} + {% plugin_left_page object %}
{% include 'circuits/inc/circuit_termination.html' with termination=termination_a side='A' %} {% include 'circuits/inc/circuit_termination.html' with termination=termination_z side='Z' %} - {% plugin_right_page circuit %} + {% plugin_right_page object %}
- {% plugin_full_width_page circuit %} + {% plugin_full_width_page object %}
{% endblock %} diff --git a/netbox/templates/circuits/inc/circuit_termination.html b/netbox/templates/circuits/inc/circuit_termination.html index aaeb114eb..477788931 100644 --- a/netbox/templates/circuits/inc/circuit_termination.html +++ b/netbox/templates/circuits/inc/circuit_termination.html @@ -4,7 +4,7 @@
{% if not termination and perms.circuits.add_circuittermination %} - + Add {% endif %} @@ -12,12 +12,12 @@ Edit - + Swap {% endif %} {% if termination and perms.circuits.delete_circuittermination %} - + Delete {% endif %} @@ -67,10 +67,10 @@ Connect
diff --git a/netbox/templates/circuits/provider.html b/netbox/templates/circuits/provider.html index a746e4eed..ce691c237 100644 --- a/netbox/templates/circuits/provider.html +++ b/netbox/templates/circuits/provider.html @@ -5,14 +5,14 @@ {% load helpers %} {% load plugins %} -{% block title %}{{ provider }}{% endblock %} +{% block title %}{{ object }}{% endblock %} {% block header %}
@@ -29,29 +29,29 @@
- {% plugin_buttons provider %} + {% plugin_buttons object %} {% if perms.circuits.add_provider %} - {% clone_button provider %} + {% clone_button object %} {% endif %} {% if perms.circuits.change_provider %} - {% edit_button provider %} + {% edit_button object %} {% endif %} {% if perms.circuits.delete_provider %} - {% delete_button provider %} + {% delete_button object %} {% endif %}
-

{{ provider }}

- {% include 'inc/created_updated.html' with obj=provider %} +

{{ object }}

+ {% include 'inc/created_updated.html' with obj=object %}
- {% custom_links provider %} + {% custom_links object %}
@@ -67,17 +67,17 @@ - + - + - + - +
ASN{{ provider.asn|placeholder }}{{ object.asn|placeholder }}
Account{{ provider.account|placeholder }}{{ object.account|placeholder }}
Customer Portal - {% if provider.portal_url %} - {{ provider.portal_url }} + {% if object.portal_url %} + {{ object.portal_url }} {% else %} {% endif %} @@ -85,35 +85,35 @@
NOC Contact{{ provider.noc_contact|render_markdown|placeholder }}{{ object.noc_contact|render_markdown|placeholder }}
Admin Contact{{ provider.admin_contact|render_markdown|placeholder }}{{ object.admin_contact|render_markdown|placeholder }}
Circuits - {{ circuits_table.rows|length }} + {{ circuits_table.rows|length }}
- {% include 'inc/custom_fields_panel.html' with obj=provider %} - {% include 'extras/inc/tags_panel.html' with tags=provider.tags.all url='circuits:provider_list' %} + {% include 'inc/custom_fields_panel.html' with obj=object %} + {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:object_list' %}
Comments
- {% if provider.comments %} - {{ provider.comments|render_markdown }} + {% if object.comments %} + {{ object.comments|render_markdown }} {% else %} None {% endif %}
- {% plugin_left_page provider %} + {% plugin_left_page object %}
@@ -123,19 +123,19 @@ {% include 'inc/table.html' with table=circuits_table %} {% if perms.circuits.add_circuit %} {% endif %}
{% include 'inc/paginator.html' with paginator=circuits_table.paginator page=circuits_table.page %} - {% plugin_right_page provider %} + {% plugin_right_page object %}
- {% plugin_full_width_page provider %} + {% plugin_full_width_page object %}
{% endblock %} diff --git a/netbox/templates/dcim/devicetype.html b/netbox/templates/dcim/devicetype.html index 0b6db7308..b1062b8e1 100644 --- a/netbox/templates/dcim/devicetype.html +++ b/netbox/templates/dcim/devicetype.html @@ -17,7 +17,7 @@
- {% plugin_buttons devicetype %} + {% plugin_buttons object %} {% if perms.dcim.change_devicetype %}
{% endif %} {% if perms.dcim.add_devicetype %} - {% clone_button devicetype %} + {% clone_button object %} {% endif %} {% if perms.dcim.change_devicetype %} - {% edit_button devicetype use_pk=True %} + {% edit_button object use_pk=True %} {% endif %} {% if perms.dcim.delete_devicetype %} - {% delete_button devicetype use_pk=True %} + {% delete_button object use_pk=True %} {% endif %}

{{ object.manufacturer }} {{ object.model }}

- {% include 'inc/created_updated.html' with obj=devicetype %} + {% include 'inc/created_updated.html' with obj=object %}
- {% custom_links devicetype %} + {% custom_links object %}