diff --git a/netbox/dcim/forms/connections.py b/netbox/dcim/forms/connections.py index ba5e51c41..443dc9143 100644 --- a/netbox/dcim/forms/connections.py +++ b/netbox/dcim/forms/connections.py @@ -15,68 +15,16 @@ def get_cable_form(a_type, b_type): for cable_end, term_cls in (('a', a_type), ('b', b_type)): - attrs[f'termination_{cable_end}_region'] = DynamicModelChoiceField( - queryset=Region.objects.all(), - label=_('Region'), - required=False, - initial_params={ - 'sites': f'$termination_{cable_end}_site' - } - ) - attrs[f'termination_{cable_end}_sitegroup'] = DynamicModelChoiceField( - queryset=SiteGroup.objects.all(), - label=_('Site group'), - required=False, - initial_params={ - 'sites': f'$termination_{cable_end}_site' - } - ) - attrs[f'termination_{cable_end}_site'] = DynamicModelChoiceField( - queryset=Site.objects.all(), - label=_('Site'), - required=False, - query_params={ - 'region_id': f'$termination_{cable_end}_region', - 'group_id': f'$termination_{cable_end}_sitegroup', - } - ) - attrs[f'termination_{cable_end}_location'] = DynamicModelChoiceField( - queryset=Location.objects.all(), - label=_('Location'), - required=False, - null_option='None', - query_params={ - 'site_id': f'$termination_{cable_end}_site' - } - ) - # Device component if hasattr(term_cls, 'device'): - attrs[f'termination_{cable_end}_rack'] = DynamicModelChoiceField( - queryset=Rack.objects.all(), - label=_('Rack'), - required=False, - null_option='None', - initial_params={ - 'devices': f'$termination_{cable_end}_device' - }, - query_params={ - 'site_id': f'$termination_{cable_end}_site', - 'location_id': f'$termination_{cable_end}_location', - } - ) attrs[f'termination_{cable_end}_device'] = DynamicModelChoiceField( queryset=Device.objects.all(), label=_('Device'), required=False, + selector=True, initial_params={ f'{term_cls._meta.model_name}s__in': f'${cable_end}_terminations' - }, - query_params={ - 'site_id': f'$termination_{cable_end}_site', - 'location_id': f'$termination_{cable_end}_location', - 'rack_id': f'$termination_{cable_end}_rack', } ) attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField( @@ -96,12 +44,9 @@ def get_cable_form(a_type, b_type): queryset=PowerPanel.objects.all(), label=_('Power Panel'), required=False, + selector=True, initial_params={ 'powerfeeds__in': f'${cable_end}_terminations' - }, - query_params={ - 'site_id': f'$termination_{cable_end}_site', - 'location_id': f'$termination_{cable_end}_location', } ) attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField( @@ -116,23 +61,12 @@ def get_cable_form(a_type, b_type): # CircuitTermination elif term_cls == CircuitTermination: - attrs[f'termination_{cable_end}_provider'] = DynamicModelChoiceField( - queryset=Provider.objects.all(), - label=_('Provider'), - initial_params={ - 'circuits': f'$termination_{cable_end}_circuit' - }, - required=False - ) attrs[f'termination_{cable_end}_circuit'] = DynamicModelChoiceField( queryset=Circuit.objects.all(), label=_('Circuit'), + selector=True, initial_params={ 'terminations__in': f'${cable_end}_terminations' - }, - query_params={ - 'provider_id': f'$termination_{cable_end}_provider', - 'site_id': f'$termination_{cable_end}_site', } ) attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField( diff --git a/netbox/templates/circuits/inc/circuit_termination.html b/netbox/templates/circuits/inc/circuit_termination.html index 12c63bd34..22c204afc 100644 --- a/netbox/templates/circuits/inc/circuit_termination.html +++ b/netbox/templates/circuits/inc/circuit_termination.html @@ -74,10 +74,10 @@ Connect {% endif %} diff --git a/netbox/templates/dcim/cable_edit.html b/netbox/templates/dcim/cable_edit.html index 1c747b44b..cbd938084 100644 --- a/netbox/templates/dcim/cable_edit.html +++ b/netbox/templates/dcim/cable_edit.html @@ -3,124 +3,87 @@ {% load helpers %} {% load form_helpers %} -{% block content-wrapper %} -
- {% render_errors form %} -
- {% csrf_token %} - {% for field in form.hidden_fields %} - {{ field }} - {% endfor %} -
-
-
-
A Side
-
- {% render_field form.termination_a_region %} - {% render_field form.termination_a_sitegroup %} - {% render_field form.termination_a_site %} - {% render_field form.termination_a_location %} - {% if 'termination_a_rack' in form.fields %} - {% render_field form.termination_a_rack %} - {% endif %} - {% if 'termination_a_device' in form.fields %} - {% render_field form.termination_a_device %} - {% endif %} - {% if 'termination_a_powerpanel' in form.fields %} - {% render_field form.termination_a_powerpanel %} - {% endif %} - {% if 'termination_a_provider' in form.fields %} - {% render_field form.termination_a_provider %} - {% endif %} - {% if 'termination_a_circuit' in form.fields %} - {% render_field form.termination_a_circuit %} - {% endif %} - {% render_field form.a_terminations %} -
-
-
-
- -
-
-
-
B Side
-
- {% render_field form.termination_b_region %} - {% render_field form.termination_b_sitegroup %} - {% render_field form.termination_b_site %} - {% render_field form.termination_b_location %} - {% if 'termination_b_rack' in form.fields %} - {% render_field form.termination_b_rack %} - {% endif %} - {% if 'termination_b_device' in form.fields %} - {% render_field form.termination_b_device %} - {% endif %} - {% if 'termination_b_powerpanel' in form.fields %} - {% render_field form.termination_b_powerpanel %} - {% endif %} - {% if 'termination_b_provider' in form.fields %} - {% render_field form.termination_b_provider %} - {% endif %} - {% if 'termination_b_circuit' in form.fields %} - {% render_field form.termination_b_circuit %} - {% endif %} - {% render_field form.b_terminations %} -
-
-
-
-
-
-
-
Cable
-
- {% render_field form.status %} - {% render_field form.type %} - {% render_field form.tenant_group %} - {% render_field form.tenant %} - {% render_field form.label %} - {% render_field form.description %} - {% render_field form.color %} -
- -
- {{ form.length }} -
-
- {{ form.length_unit }} -
-
-
- {% render_field form.tags %} -
-
-
-
Comments
-
- {% render_field form.comments %} -
-
- {% if form.custom_fields %} -
-
Custom Fields
-
- {% render_custom_fields form %} -
-
- {% endif %} -
-
-
-
- {% if object.pk %} - - {% else %} - - {% endif %} - Cancel -
-
-
+{% block form %} + + {# A side termination #} +
+
+
A Side
+
+ {% if 'termination_a_device' in form.fields %} + {% render_field form.termination_a_device %} + {% endif %} + {% if 'termination_a_powerpanel' in form.fields %} + {% render_field form.termination_a_powerpanel %} + {% endif %} + {% if 'termination_a_circuit' in form.fields %} + {% render_field form.termination_a_circuit %} + {% endif %} + {% render_field form.a_terminations %}
+ + {# B side termination #} +
+
+
B Side
+
+ {% if 'termination_b_device' in form.fields %} + {% render_field form.termination_b_device %} + {% endif %} + {% if 'termination_b_powerpanel' in form.fields %} + {% render_field form.termination_b_powerpanel %} + {% endif %} + {% if 'termination_b_circuit' in form.fields %} + {% render_field form.termination_b_circuit %} + {% endif %} + {% render_field form.b_terminations %} +
+ + {# Cable attributes #} +
+
+
Cable
+
+ {% render_field form.status %} + {% render_field form.type %} + {% render_field form.label %} + {% render_field form.description %} + {% render_field form.color %} +
+ +
+ {{ form.length }} +
+
+ {{ form.length_unit }} +
+
+
+ {% render_field form.tags %} +
+ +
+
+
Tenancy
+
+ {% render_field form.tenant_group %} + {% render_field form.tenant %} +
+ + {% if form.custom_fields %} +
+
+
Custom Fields
+
+ {% render_custom_fields form %} +
+ {% endif %} + + {% if form.comments %} +
+
Comments
+ {% render_field form.comments %} +
+ {% endif %} + {% endblock %} diff --git a/netbox/templates/dcim/consoleport.html b/netbox/templates/dcim/consoleport.html index dee57e28b..0f2d2bb80 100644 --- a/netbox/templates/dcim/consoleport.html +++ b/netbox/templates/dcim/consoleport.html @@ -71,13 +71,13 @@
diff --git a/netbox/templates/dcim/consoleserverport.html b/netbox/templates/dcim/consoleserverport.html index cd447d11d..c52105c96 100644 --- a/netbox/templates/dcim/consoleserverport.html +++ b/netbox/templates/dcim/consoleserverport.html @@ -71,13 +71,13 @@ diff --git a/netbox/templates/dcim/frontport.html b/netbox/templates/dcim/frontport.html index 2ef955fe9..e5f1df5ae 100644 --- a/netbox/templates/dcim/frontport.html +++ b/netbox/templates/dcim/frontport.html @@ -109,22 +109,22 @@ diff --git a/netbox/templates/dcim/interface.html b/netbox/templates/dcim/interface.html index 0566a0109..1053f60f3 100644 --- a/netbox/templates/dcim/interface.html +++ b/netbox/templates/dcim/interface.html @@ -182,16 +182,16 @@ diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index 4b8a6dc34..bda324f64 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -122,7 +122,7 @@ {% if not object.mark_connected and not object.cable %}