diff --git a/docs/release-notes/version-3.2.md b/docs/release-notes/version-3.2.md index dcdc2a6d18..db52f0150b 100644 --- a/docs/release-notes/version-3.2.md +++ b/docs/release-notes/version-3.2.md @@ -158,6 +158,7 @@ Where it is desired to limit the range of available VLANs within a group, users * [#8763](https://github.com/netbox-community/netbox/issues/8763) - Fix inventory item component assignment * [#8764](https://github.com/netbox-community/netbox/issues/8764) - Correct view name resolution for dynamic form fields * [#8791](https://github.com/netbox-community/netbox/issues/8791) - Fix display of form validation failures during device component creation +* [#8792](https://github.com/netbox-community/netbox/issues/8792) - Fix creation of circuit terminations via UI ### Other Changes diff --git a/netbox/circuits/forms/models.py b/netbox/circuits/forms/models.py index 2246573ba6..869fe03c6f 100644 --- a/netbox/circuits/forms/models.py +++ b/netbox/circuits/forms/models.py @@ -125,6 +125,19 @@ class Meta: class CircuitTerminationForm(BootstrapMixin, forms.ModelForm): + provider = DynamicModelChoiceField( + queryset=Provider.objects.all(), + required=False, + initial_params={ + 'circuits': '$circuit' + } + ) + circuit = DynamicModelChoiceField( + queryset=Circuit.objects.all(), + query_params={ + 'provider_id': '$provider', + }, + ) region = DynamicModelChoiceField( queryset=Region.objects.all(), required=False, @@ -155,8 +168,8 @@ class CircuitTerminationForm(BootstrapMixin, forms.ModelForm): class Meta: model = CircuitTermination fields = [ - 'term_side', 'region', 'site_group', 'site', 'provider_network', 'mark_connected', 'port_speed', - 'upstream_speed', 'xconnect_id', 'pp_info', 'description', + 'provider', 'circuit', 'term_side', 'region', 'site_group', 'site', 'provider_network', 'mark_connected', + 'port_speed', 'upstream_speed', 'xconnect_id', 'pp_info', 'description', ] help_texts = { 'port_speed': "Physical circuit speed", @@ -164,12 +177,7 @@ class Meta: 'pp_info': "Patch panel ID and port number(s)" } widgets = { - 'term_side': forms.HiddenInput(), + 'term_side': StaticSelect(), 'port_speed': SelectSpeedWidget(), 'upstream_speed': SelectSpeedWidget(), } - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - self.fields['provider_network'].widget.add_query_param('provider_id', self.instance.circuit.provider_id) diff --git a/netbox/circuits/tests/test_views.py b/netbox/circuits/tests/test_views.py index 851d52ae8a..d8ad27d72c 100644 --- a/netbox/circuits/tests/test_views.py +++ b/netbox/circuits/tests/test_views.py @@ -218,6 +218,7 @@ def setUpTestData(cls): CircuitTermination.objects.bulk_create(circuit_terminations) cls.form_data = { + 'circuit': circuits[2].pk, 'term_side': 'A', 'site': sites[2].pk, 'description': 'New description', diff --git a/netbox/circuits/urls.py b/netbox/circuits/urls.py index 7feeb28f6a..f3ee64cf01 100644 --- a/netbox/circuits/urls.py +++ b/netbox/circuits/urls.py @@ -57,7 +57,7 @@ path('circuits//terminations/swap/', views.CircuitSwapTerminations.as_view(), name='circuit_terminations_swap'), # Circuit terminations - path('circuits//terminations/add/', views.CircuitTerminationEditView.as_view(), name='circuittermination_add'), + path('circuit-terminations/add/', views.CircuitTerminationEditView.as_view(), name='circuittermination_add'), path('circuit-terminations//edit/', views.CircuitTerminationEditView.as_view(), name='circuittermination_edit'), path('circuit-terminations//delete/', views.CircuitTerminationDeleteView.as_view(), name='circuittermination_delete'), path('circuit-terminations//connect//', CableCreateView.as_view(), name='circuittermination_connect', kwargs={'termination_a_type': CircuitTermination}), diff --git a/netbox/circuits/views.py b/netbox/circuits/views.py index 5956e82716..e06da906bb 100644 --- a/netbox/circuits/views.py +++ b/netbox/circuits/views.py @@ -318,14 +318,6 @@ class CircuitTerminationEditView(generic.ObjectEditView): model_form = forms.CircuitTerminationForm template_name = 'circuits/circuittermination_edit.html' - def alter_object(self, obj, request, url_args, url_kwargs): - if 'circuit' in url_kwargs: - obj.circuit = get_object_or_404(Circuit, pk=url_kwargs['circuit']) - return obj - - def get_return_url(self, request, obj): - return obj.circuit.get_absolute_url() - class CircuitTerminationDeleteView(generic.ObjectDeleteView): queryset = CircuitTermination.objects.all() diff --git a/netbox/templates/circuits/circuittermination_edit.html b/netbox/templates/circuits/circuittermination_edit.html index 3f3fad8126..f8393f9454 100644 --- a/netbox/templates/circuits/circuittermination_edit.html +++ b/netbox/templates/circuits/circuittermination_edit.html @@ -2,31 +2,14 @@ {% load static %} {% load form_helpers %} -{% block title %}{{ object.circuit.provider }} {{ object.circuit }} - Side {{ form.term_side.value }}{% endblock %} - {% block form %}
Circuit Termination
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
+ {% render_field form.provider %} + {% render_field form.circuit %} + {% render_field form.term_side %} {% render_field form.mark_connected %} {% with providernetwork_tab_active=form.initial.provider_network %}
diff --git a/netbox/templates/circuits/inc/circuit_termination.html b/netbox/templates/circuits/inc/circuit_termination.html index 89b7891a29..d0a739c337 100644 --- a/netbox/templates/circuits/inc/circuit_termination.html +++ b/netbox/templates/circuits/inc/circuit_termination.html @@ -5,7 +5,7 @@ Termination - {{ side }} Side
{% if not termination and perms.circuits.add_circuittermination %} - + Add {% endif %}