-
-
Save Gelob/0914c3ee5219b70e63d15b2b70b9d9bc to your computer and use it in GitHub Desktop.
Netbox hardcoded paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/netbox/circuits/forms.py b/netbox/circuits/forms.py | |
index 7046b8e..4cd6919 100644 | |
--- a/netbox/circuits/forms.py | |
+++ b/netbox/circuits/forms.py | |
@@ -82,16 +82,16 @@ class CircuitTypeBulkDeleteForm(ConfirmationForm): | |
class CircuitForm(forms.ModelForm, BootstrapMixin): | |
site = forms.ModelChoiceField(queryset=Site.objects.all(), widget=forms.Select(attrs={'filter-for': 'rack'})) | |
rack = forms.ModelChoiceField(queryset=Rack.objects.all(), required=False, label='Rack', | |
- widget=APISelect(api_url='/api/dcim/racks/?site_id={{site}}', | |
+ widget=APISelect(api_url='/netbox/api/dcim/racks/?site_id={{site}}', | |
attrs={'filter-for': 'device'})) | |
device = forms.ModelChoiceField(queryset=Device.objects.all(), required=False, label='Device', | |
- widget=APISelect(api_url='/api/dcim/devices/?rack_id={{rack}}', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/?rack_id={{rack}}', | |
attrs={'filter-for': 'interface'})) | |
livesearch = forms.CharField(required=False, label='Device', widget=Livesearch( | |
query_key='q', query_url='dcim-api:device_list', field_to_update='device') | |
) | |
interface = forms.ModelChoiceField(queryset=Interface.objects.all(), required=False, label='Interface', | |
- widget=APISelect(api_url='/api/dcim/devices/{{device}}/interfaces/?type=physical', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/{{device}}/interfaces/?type=physical', | |
disabled_indicator='is_connected')) | |
comments = CommentField() | |
diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py | |
index 65b6e77..fe93b14 100644 | |
--- a/netbox/dcim/forms.py | |
+++ b/netbox/dcim/forms.py | |
@@ -105,7 +105,7 @@ class RackGroupFilterForm(forms.Form, BootstrapMixin): | |
class RackForm(forms.ModelForm, BootstrapMixin): | |
group = forms.ModelChoiceField(queryset=RackGroup.objects.all(), required=False, label='Group', widget=APISelect( | |
- api_url='/api/dcim/rack-groups/?site_id={{site}}', | |
+ api_url='/netbox/api/dcim/rack-groups/?site_id={{site}}', | |
)) | |
comments = CommentField() | |
@@ -322,18 +322,18 @@ class PlatformBulkDeleteForm(ConfirmationForm): | |
class DeviceForm(forms.ModelForm, BootstrapMixin): | |
site = forms.ModelChoiceField(queryset=Site.objects.all(), widget=forms.Select(attrs={'filter-for': 'rack'})) | |
rack = forms.ModelChoiceField(queryset=Rack.objects.all(), widget=APISelect( | |
- api_url='/api/dcim/racks/?site_id={{site}}', | |
+ api_url='/netbox/api/dcim/racks/?site_id={{site}}', | |
display_field='display_name', | |
attrs={'filter-for': 'position'} | |
)) | |
position = forms.TypedChoiceField(required=False, empty_value=None, | |
help_text="For multi-U devices, this is the lowest occupied rack unit.", | |
- widget=APISelect(api_url='/api/dcim/racks/{{rack}}/rack-units/?face={{face}}', | |
+ widget=APISelect(api_url='/netbox/api/dcim/racks/{{rack}}/rack-units/?face={{face}}', | |
disabled_indicator='device')) | |
manufacturer = forms.ModelChoiceField(queryset=Manufacturer.objects.all(), | |
widget=forms.Select(attrs={'filter-for': 'device_type'})) | |
device_type = forms.ModelChoiceField(queryset=DeviceType.objects.all(), label='Model', widget=APISelect( | |
- api_url='/api/dcim/device-types/?manufacturer_id={{manufacturer}}', | |
+ api_url='/netbox/api/dcim/device-types/?manufacturer_id={{manufacturer}}', | |
display_field='model' | |
)) | |
comments = CommentField() | |
@@ -606,13 +606,13 @@ class ConsolePortConnectionForm(forms.ModelForm, BootstrapMixin): | |
rack = forms.ModelChoiceField(queryset=Rack.objects.all(), label='Rack', required=False, | |
widget=forms.Select(attrs={'filter-for': 'console_server'})) | |
console_server = forms.ModelChoiceField(queryset=Device.objects.all(), label='Console Server', required=False, | |
- widget=APISelect(api_url='/api/dcim/devices/?rack_id={{rack}}&is_console_server=True', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/?rack_id={{rack}}&is_console_server=True', | |
attrs={'filter-for': 'cs_port'})) | |
livesearch = forms.CharField(required=False, label='Console Server', widget=Livesearch( | |
query_key='q', query_url='dcim-api:device_list', field_to_update='console_server') | |
) | |
cs_port = forms.ModelChoiceField(queryset=ConsoleServerPort.objects.all(), label='Port', | |
- widget=APISelect(api_url='/api/dcim/devices/{{console_server}}/console-server-ports/', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/{{console_server}}/console-server-ports/', | |
disabled_indicator='connected_console')) | |
class Meta: | |
@@ -673,13 +673,13 @@ class ConsoleServerPortConnectionForm(forms.Form, BootstrapMixin): | |
rack = forms.ModelChoiceField(queryset=Rack.objects.all(), label='Rack', required=False, | |
widget=forms.Select(attrs={'filter-for': 'device'})) | |
device = forms.ModelChoiceField(queryset=Device.objects.all(), label='Device', required=False, | |
- widget=APISelect(api_url='/api/dcim/devices/?rack_id={{rack}}', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/?rack_id={{rack}}', | |
attrs={'filter-for': 'port'})) | |
livesearch = forms.CharField(required=False, label='Device', widget=Livesearch( | |
query_key='q', query_url='dcim-api:device_list', field_to_update='device') | |
) | |
port = forms.ModelChoiceField(queryset=ConsolePort.objects.all(), label='Port', | |
- widget=APISelect(api_url='/api/dcim/devices/{{device}}/console-ports/', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/{{device}}/console-ports/', | |
disabled_indicator='cs_port')) | |
connection_status = forms.BooleanField(required=False, initial=CONNECTION_STATUS_CONNECTED, label='Status', | |
widget=forms.Select(choices=CONNECTION_STATUS_CHOICES)) | |
@@ -802,13 +802,13 @@ class PowerPortConnectionForm(forms.ModelForm, BootstrapMixin): | |
rack = forms.ModelChoiceField(queryset=Rack.objects.all(), label='Rack', required=False, | |
widget=forms.Select(attrs={'filter-for': 'pdu'})) | |
pdu = forms.ModelChoiceField(queryset=Device.objects.all(), label='PDU', required=False, | |
- widget=APISelect(api_url='/api/dcim/devices/?rack_id={{rack}}&is_pdu=True', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/?rack_id={{rack}}&is_pdu=True', | |
attrs={'filter-for': 'power_outlet'})) | |
livesearch = forms.CharField(required=False, label='PDU', widget=Livesearch( | |
query_key='q', query_url='dcim-api:device_list', field_to_update='pdu') | |
) | |
power_outlet = forms.ModelChoiceField(queryset=PowerOutlet.objects.all(), label='Outlet', | |
- widget=APISelect(api_url='/api/dcim/devices/{{pdu}}/power-outlets/', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/{{pdu}}/power-outlets/', | |
disabled_indicator='connected_port')) | |
class Meta: | |
@@ -869,13 +869,13 @@ class PowerOutletConnectionForm(forms.Form, BootstrapMixin): | |
rack = forms.ModelChoiceField(queryset=Rack.objects.all(), label='Rack', required=False, | |
widget=forms.Select(attrs={'filter-for': 'device'})) | |
device = forms.ModelChoiceField(queryset=Device.objects.all(), label='Device', required=False, | |
- widget=APISelect(api_url='/api/dcim/devices/?rack_id={{rack}}', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/?rack_id={{rack}}', | |
attrs={'filter-for': 'port'})) | |
livesearch = forms.CharField(required=False, label='Device', widget=Livesearch( | |
query_key='q', query_url='dcim-api:device_list', field_to_update='device') | |
) | |
port = forms.ModelChoiceField(queryset=PowerPort.objects.all(), label='Port', | |
- widget=APISelect(api_url='/api/dcim/devices/{{device}}/power-ports/', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/{{device}}/power-ports/', | |
disabled_indicator='power_outlet')) | |
connection_status = forms.BooleanField(required=False, initial=CONNECTION_STATUS_CONNECTED, label='Status', | |
widget=forms.Select(choices=CONNECTION_STATUS_CHOICES)) | |
@@ -944,13 +944,13 @@ class InterfaceConnectionForm(forms.ModelForm, BootstrapMixin): | |
rack_b = forms.ModelChoiceField(queryset=Rack.objects.all(), label='Rack', required=False, | |
widget=forms.Select(attrs={'filter-for': 'device_b'})) | |
device_b = forms.ModelChoiceField(queryset=Device.objects.all(), label='Device', required=False, | |
- widget=APISelect(api_url='/api/dcim/devices/?rack_id={{rack_b}}', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/?rack_id={{rack_b}}', | |
attrs={'filter-for': 'interface_b'})) | |
livesearch = forms.CharField(required=False, label='Device', widget=Livesearch( | |
query_key='q', query_url='dcim-api:device_list', field_to_update='device_b') | |
) | |
interface_b = forms.ModelChoiceField(queryset=Interface.objects.all(), label='Interface', | |
- widget=APISelect(api_url='/api/dcim/devices/{{device_b}}/interfaces/?type=physical', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/{{device_b}}/interfaces/?type=physical', | |
disabled_indicator='is_connected')) | |
class Meta: | |
diff --git a/netbox/dcim/tests/test_apis.py b/netbox/dcim/tests/test_apis.py | |
index f36fc4e..bdeb982 100644 | |
--- a/netbox/dcim/tests/test_apis.py | |
+++ b/netbox/dcim/tests/test_apis.py | |
@@ -50,7 +50,7 @@ class SiteTest(APITestCase): | |
'embed_link', | |
] | |
- def test_get_list(self, endpoint='/api/dcim/sites/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/sites/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -60,7 +60,7 @@ class SiteTest(APITestCase): | |
sorted(self.standard_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/sites/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/sites/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -69,7 +69,7 @@ class SiteTest(APITestCase): | |
sorted(self.standard_fields), | |
) | |
- def test_get_site_list_rack(self, endpoint='/api/dcim/sites/1/racks/'): | |
+ def test_get_site_list_rack(self, endpoint='/netbox/api/dcim/sites/1/racks/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -84,7 +84,7 @@ class SiteTest(APITestCase): | |
sorted(self.nested_fields), | |
) | |
- def test_get_site_list_graphs(self, endpoint='/api/dcim/sites/1/graphs/'): | |
+ def test_get_site_list_graphs(self, endpoint='/netbox/api/dcim/sites/1/graphs/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -132,7 +132,7 @@ class RackTest(APITestCase): | |
'rear_units' | |
] | |
- def test_get_list(self, endpoint='/api/dcim/racks/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/racks/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -146,7 +146,7 @@ class RackTest(APITestCase): | |
sorted(SiteTest.nested_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/racks/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/racks/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -175,7 +175,7 @@ class ManufacturersTest(APITestCase): | |
nested_fields = standard_fields | |
- def test_get_list(self, endpoint='/api/dcim/manufacturers/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/manufacturers/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -185,7 +185,7 @@ class ManufacturersTest(APITestCase): | |
sorted(self.standard_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/manufacturers/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/manufacturers/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -218,7 +218,7 @@ class DeviceTypeTest(APITestCase): | |
'slug' | |
] | |
- def test_get_list(self, endpoint='/api/dcim/device-types/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/device-types/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -228,7 +228,7 @@ class DeviceTypeTest(APITestCase): | |
sorted(self.standard_fields), | |
) | |
- def test_detail_list(self, endpoint='/api/dcim/device-types/1/'): | |
+ def test_detail_list(self, endpoint='/netbox/api/dcim/device-types/1/'): | |
# TODO: details returns list view. | |
# response = self.client.get(endpoint) | |
# content = json.loads(response.content) | |
@@ -252,7 +252,7 @@ class DeviceRolesTest(APITestCase): | |
nested_fields = ['id', 'name', 'slug'] | |
- def test_get_list(self, endpoint='/api/dcim/device-roles/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/device-roles/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -262,7 +262,7 @@ class DeviceRolesTest(APITestCase): | |
sorted(self.standard_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/device-roles/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/device-roles/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -280,7 +280,7 @@ class PlatformsTest(APITestCase): | |
nested_fields = ['id', 'name', 'slug'] | |
- def test_get_list(self, endpoint='/api/dcim/platforms/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/platforms/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -290,7 +290,7 @@ class PlatformsTest(APITestCase): | |
sorted(self.standard_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/platforms/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/platforms/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -322,7 +322,7 @@ class DeviceTest(APITestCase): | |
nested_fields = ['id', 'name', 'display_name'] | |
- def test_get_list(self, endpoint='/api/dcim/devices/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/devices/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -349,7 +349,7 @@ class DeviceTest(APITestCase): | |
sorted(RackTest.nested_fields), | |
) | |
- def test_get_list_flat(self, endpoint='/api/dcim/devices/?format=json_flat'): | |
+ def test_get_list_flat(self, endpoint='/netbox/api/dcim/devices/?format=json_flat'): | |
flat_fields = [ | |
'comments', | |
@@ -390,7 +390,7 @@ class DeviceTest(APITestCase): | |
sorted(flat_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/devices/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/devices/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -408,7 +408,7 @@ class ConsoleServerPortsTest(APITestCase): | |
nested_fields = ['id', 'device', 'name'] | |
- def test_get_list(self, endpoint='/api/dcim/devices/9/console-server-ports/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/devices/9/console-server-ports/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -430,7 +430,7 @@ class ConsolePortsTest(APITestCase): | |
nested_fields = ['id', 'device', 'name'] | |
- def test_get_list(self, endpoint='/api/dcim/devices/1/console-ports/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/devices/1/console-ports/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -448,7 +448,7 @@ class ConsolePortsTest(APITestCase): | |
sorted(ConsoleServerPortsTest.nested_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/console-ports/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/console-ports/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -469,7 +469,7 @@ class PowerPortsTest(APITestCase): | |
nested_fields = ['id', 'device', 'name'] | |
- def test_get_list(self, endpoint='/api/dcim/devices/1/power-ports/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/devices/1/power-ports/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -483,7 +483,7 @@ class PowerPortsTest(APITestCase): | |
sorted(DeviceTest.nested_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/power-ports/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/power-ports/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -504,7 +504,7 @@ class PowerOutletsTest(APITestCase): | |
nested_fields = ['id', 'device', 'name'] | |
- def test_get_list(self, endpoint='/api/dcim/devices/11/power-outlets/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/devices/11/power-outlets/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -552,7 +552,7 @@ class InterfaceTest(APITestCase): | |
'connection_status', | |
] | |
- def test_get_list(self, endpoint='/api/dcim/devices/1/interfaces/'): | |
+ def test_get_list(self, endpoint='/netbox/api/dcim/devices/1/interfaces/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -566,7 +566,7 @@ class InterfaceTest(APITestCase): | |
sorted(DeviceTest.nested_fields), | |
) | |
- def test_get_detail(self, endpoint='/api/dcim/interfaces/1/'): | |
+ def test_get_detail(self, endpoint='/netbox/api/dcim/interfaces/1/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -579,7 +579,7 @@ class InterfaceTest(APITestCase): | |
sorted(DeviceTest.nested_fields), | |
) | |
- def test_get_graph_list(self, endpoint='/api/dcim/interfaces/1/graphs/'): | |
+ def test_get_graph_list(self, endpoint='/netbox/api/dcim/interfaces/1/graphs/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -589,7 +589,7 @@ class InterfaceTest(APITestCase): | |
sorted(SiteTest.graph_fields), | |
) | |
- def test_get_interface_connections(self, endpoint='/api/dcim/interface-connections/4/'): | |
+ def test_get_interface_connections(self, endpoint='/netbox/api/dcim/interface-connections/4/'): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | |
@@ -611,7 +611,7 @@ class RelatedConnectionsTest(APITestCase): | |
] | |
def test_get_list(self, endpoint=( | |
- '/api/dcim/related-connections/' | |
+ '/netbox/api/dcim/related-connections/' | |
'?peer-device=test1-edge1&peer-interface=xe-0/0/3')): | |
response = self.client.get(endpoint) | |
content = json.loads(response.content) | |
diff --git a/netbox/ipam/forms.py b/netbox/ipam/forms.py | |
index 0c7a411..c7ca767 100644 | |
--- a/netbox/ipam/forms.py | |
+++ b/netbox/ipam/forms.py | |
@@ -144,7 +144,7 @@ class PrefixForm(forms.ModelForm, BootstrapMixin): | |
site = forms.ModelChoiceField(queryset=Site.objects.all(), required=False, label='Site', | |
widget=forms.Select(attrs={'filter-for': 'vlan'})) | |
vlan = forms.ModelChoiceField(queryset=VLAN.objects.all(), required=False, label='VLAN', | |
- widget=APISelect(api_url='/api/ipam/vlans/?site_id={{site}}', | |
+ widget=APISelect(api_url='/netbox/api/ipam/vlans/?site_id={{site}}', | |
display_field='display_name')) | |
class Meta: | |
@@ -270,13 +270,13 @@ class IPAddressForm(forms.ModelForm, BootstrapMixin): | |
nat_site = forms.ModelChoiceField(queryset=Site.objects.all(), required=False, label='Site', | |
widget=forms.Select(attrs={'filter-for': 'nat_device'})) | |
nat_device = forms.ModelChoiceField(queryset=Device.objects.all(), required=False, label='Device', | |
- widget=APISelect(api_url='/api/dcim/devices/?site_id={{nat_site}}', | |
+ widget=APISelect(api_url='/netbox/api/dcim/devices/?site_id={{nat_site}}', | |
attrs={'filter-for': 'nat_inside'})) | |
livesearch = forms.CharField(required=False, label='IP Address', widget=Livesearch( | |
query_key='q', query_url='ipam-api:ipaddress_list', field_to_update='nat_inside', obj_label='address') | |
) | |
nat_inside = forms.ModelChoiceField(queryset=IPAddress.objects.all(), required=False, label='NAT (Inside)', | |
- widget=APISelect(api_url='/api/ipam/ip-addresses/?device_id={{nat_device}}', | |
+ widget=APISelect(api_url='/netbox/api/ipam/ip-addresses/?device_id={{nat_device}}', | |
display_field='address')) | |
class Meta: | |
diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py | |
index 7e4a223..6733fed 100644 | |
--- a/netbox/netbox/settings.py | |
+++ b/netbox/netbox/settings.py | |
# Middleware | |
MIDDLEWARE_CLASSES = ( | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
@@ -125,7 +128,7 @@ USE_TZ = True | |
# Static files (CSS, JavaScript, Images) | |
# https://docs.djangoproject.com/en/1.8/howto/static-files/ | |
STATIC_ROOT = BASE_DIR + '/static/' | |
-STATIC_URL = '/static/' | |
+STATIC_URL = '/netbox/static/' | |
STATICFILES_DIRS = ( | |
os.path.join(BASE_DIR, "project-static"), | |
) | |
@@ -136,9 +139,9 @@ MESSAGE_TAGS = { | |
} | |
# Authentication URLs | |
-LOGIN_URL = '/login/' | |
-LOGIN_REDIRECT_URL = '/' | |
-LOGOUT_URL = '/logout/' | |
+LOGIN_URL = '/netbox/login/' | |
+LOGIN_REDIRECT_URL = '/netbox/' | |
+LOGOUT_URL = '/netbox/logout/' | |
# Secrets | |
SECRETS_MIN_PUBKEY_SIZE = 2048 | |
@@ -150,7 +153,7 @@ REST_FRAMEWORK = { | |
# Swagger settings (API docs) | |
SWAGGER_SETTINGS = { | |
- 'base_path': '{}/api/docs'.format(ALLOWED_HOSTS[0]), | |
+ 'base_path': '{}/netbox/api/docs'.format(ALLOWED_HOSTS[0]), | |
} | |
@@ -158,3 +161,64 @@ try: | |
HOSTNAME = socket.gethostname() | |
except: | |
HOSTNAME = 'localhost' | |
+ | |
+FORCE_SCRIPT_NAME = '/netbox' | |
+ | |
diff --git a/netbox/project-static/js/secrets.js b/netbox/project-static/js/secrets.js | |
index 21d8656..0ce03cf 100644 | |
--- a/netbox/project-static/js/secrets.js | |
+++ b/netbox/project-static/js/secrets.js | |
@@ -44,7 +44,7 @@ $(document).ready(function() { | |
$('#generate_keypair').click(function() { | |
$('#new_keypair_modal').modal('show'); | |
$.ajax({ | |
- url: '/api/secrets/generate-keys/', | |
+ url: '/netbox/api/secrets/generate-keys/', | |
type: 'GET', | |
dataType: 'json', | |
success: function (response, status) { | |
@@ -71,7 +71,7 @@ $(document).ready(function() { | |
function unlock_secret(secret_id, private_key) { | |
var csrf_token = $('input[name=csrfmiddlewaretoken]').val(); | |
$.ajax({ | |
- url: '/api/secrets/secrets/' + secret_id + '/', | |
+ url: '/netbox/api/secrets/secrets/' + secret_id + '/', | |
type: 'POST', | |
data: { | |
private_key: private_key | |
diff --git a/netbox/templates/_base.html b/netbox/templates/_base.html | |
index bb6d8bd..9b97f3e 100644 | |
--- a/netbox/templates/_base.html | |
+++ b/netbox/templates/_base.html | |
@@ -19,7 +19,7 @@ | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
- <a class="navbar-brand" href="/">NetBox</a> | |
+ <a class="navbar-brand" href="/netbox">NetBox</a> | |
</div> | |
<div id="navbar" class="navbar-collapse collapse"> | |
{% if request.user.is_authenticated or not settings.LOGIN_REQUIRED %} | |
@@ -253,7 +253,7 @@ | |
<div class="col-md-4 text-right"> | |
<p class="text-muted"> | |
<i class="fa fa-fw fa-book text-primary"></i> <a href="{% url 'docs_root' %}">Docs</a> · | |
- <i class="fa fa-fw fa-cloud text-primary"></i> <a href="/api/docs/">API</a> · | |
+ <i class="fa fa-fw fa-cloud text-primary"></i> <a href="/netbox/api/docs/">API</a> · | |
<i class="fa fa-fw fa-code text-primary"></i> <a href="https://github.com/digitalocean/netbox">Code</a> | |
</p> | |
</div> | |
diff --git a/netbox/utilities/middleware.py b/netbox/utilities/middleware.py | |
index 563e4a0..e759716 100644 | |
--- a/netbox/utilities/middleware.py | |
+++ b/netbox/utilities/middleware.py | |
@@ -11,5 +11,5 @@ class LoginRequiredMiddleware: | |
""" | |
def process_request(self, request): | |
if LOGIN_REQUIRED and not request.user.is_authenticated(): | |
- if request.path_info != settings.LOGIN_URL: | |
+ if request.path_info != settings.LOGIN_URL and '/netbox' + request.path_info != settings.LOGIN_URL: | |
return HttpResponseRedirect(settings.LOGIN_URL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment