Skip to content

Commit

Permalink
Cleanup legacy get_saved_topology
Browse files Browse the repository at this point in the history
  • Loading branch information
iDebugAll committed Nov 28, 2024
1 parent 82f4cba commit 6df00f1
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions nextbox_ui_plugin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,40 +436,6 @@ def get_topology(nb_devices_qs, params):
return topology_dict, device_roles, multi_cable_connections, all_device_tags


def get_saved_topology(id):
topology_dict = {}
device_roles = []
device_tags = []
device_roles_detailed = []
device_tags_detailed = []
layout_context = {}
topology_data = SavedTopology.objects.get(id=id)
if not topology_data:
return topology_dict, device_roles, device_tags, layout_context
topology_dict = dict(topology_data.topology)
if 'nodes' not in topology_dict:
return topology_dict, device_roles, device_tags, layout_context
device_roles = list(set([str(d.get('deviceRole')) for d in topology_dict['nodes'] if d.get('deviceRole')]))
for device_role in device_roles:
is_visible = not (device_role in UNDISPLAYED_DEVICE_ROLE_SLUGS)
device_role_obj = DeviceRole.objects.get(slug=device_role)
if not device_role_obj:
device_roles_detailed.append((device_role, device_role, is_visible))
continue
device_roles_detailed.append((device_role_obj.slug, device_role_obj.name, is_visible))
device_roles_detailed.sort(key=lambda i: get_node_layer_sort_preference(i[0]))
device_tags = set()
for device in topology_dict['nodes']:
if 'tags' not in device:
continue
for tag in device['tags']:
device_tags.add(str(tag))
device_tags = list(device_tags)
device_tags_detailed = list([(tag, not tag_is_hidden(tag)) for tag in device_tags])
layout_context = dict(topology_data.layout_context)
return topology_dict, device_roles_detailed, device_tags_detailed, layout_context


class TopologyView(PermissionRequiredMixin, View):
"""Generic Topology View"""
permission_required = ('dcim.view_site', 'dcim.view_device', 'dcim.view_cable')
Expand Down

0 comments on commit 6df00f1

Please sign in to comment.