|
3 | 3 |
|
4 | 4 | from circuits.models import Circuit
|
5 | 5 | from dcim.models import Device, DeviceRole, PowerFeed, PowerPanel
|
| 6 | +from extras.models import SavedFilter |
6 | 7 | from django.conf import settings
|
7 | 8 | from django.contrib.auth.mixins import PermissionRequiredMixin
|
8 | 9 | from django.contrib.contenttypes.models import ContentType
|
@@ -108,7 +109,30 @@ def list(self, request):
|
108 | 109 |
|
109 | 110 | if request.GET:
|
110 | 111 |
|
111 |
| - save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks,show_neighbors = get_query_settings(request) |
| 112 | + filter_id, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks,show_neighbors = get_query_settings(request) |
| 113 | + |
| 114 | + # Read options from saved filters as NetBox does not handle custom plugin filters |
| 115 | + if "filter_id" in request.GET and request.GET["filter_id"] != '': |
| 116 | + try: |
| 117 | + saved_filter = SavedFilter.objects.get(pk=filter_id) |
| 118 | + saved_filter_params = getattr(saved_filter, 'parameters') |
| 119 | + |
| 120 | + if save_coords == False and 'save_coords' in saved_filter_params: save_coords = saved_filter_params['save_coords'] |
| 121 | + if show_power == False and 'show_power' in saved_filter_params: show_power = saved_filter_params['show_power'] |
| 122 | + if show_circuit == False and 'show_circuit' in saved_filter_params: show_circuit = saved_filter_params['show_circuit'] |
| 123 | + if show_logical_connections == False and 'show_logical_connections' in saved_filter_params: show_logical_connections = saved_filter_params['show_logical_connections'] |
| 124 | + if show_single_cable_logical_conns == False and 'show_single_cable_logical_conns' in saved_filter_params: show_single_cable_logical_conns = saved_filter_params['show_single_cable_logical_conns'] |
| 125 | + if show_cables == False and 'show_cables' in saved_filter_params: show_cables = saved_filter_params['show_cables'] |
| 126 | + if show_wireless == False and 'show_wireless' in saved_filter_params: show_wireless = saved_filter_params['show_wireless'] |
| 127 | + if group_sites == False and 'group_sites' in saved_filter_params: group_sites = saved_filter_params['group_sites'] |
| 128 | + if group_locations == False and 'group_locations' in saved_filter_params: group_locations = saved_filter_params['group_locations'] |
| 129 | + if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks'] |
| 130 | + if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors'] |
| 131 | + except SavedFilter.DoesNotExist: # filter_id not found |
| 132 | + pass |
| 133 | + except Exception as inst: |
| 134 | + print(type(inst)) |
| 135 | + |
112 | 136 | if 'group' not in request.query_params:
|
113 | 137 | group_id = "default"
|
114 | 138 | else:
|
|
0 commit comments