mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #3310: Pre-select site/rack for B side when creating a new cable
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
# v2.7.3 (FUTURE)
|
# v2.7.3 (FUTURE)
|
||||||
|
|
||||||
|
## Enhancements
|
||||||
|
|
||||||
|
* [#3310](https://github.com/netbox-community/netbox/issues/3310) - Pre-select site/rack for B side when creating a new cable
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
|
|
||||||
* [#3983](https://github.com/netbox-community/netbox/issues/3983) - Permit the creation of multiple unnamed devices
|
* [#3983](https://github.com/netbox-community/netbox/issues/3983) - Permit the creation of multiple unnamed devices
|
||||||
|
@ -3168,6 +3168,11 @@ class ConnectCableToDeviceForm(BootstrapMixin, ChainedFieldsMixin, forms.ModelFo
|
|||||||
'termination_b_site', 'termination_b_rack', 'termination_b_device', 'termination_b_id', 'type', 'status',
|
'termination_b_site', 'termination_b_rack', 'termination_b_device', 'termination_b_id', 'type', 'status',
|
||||||
'label', 'color', 'length', 'length_unit',
|
'label', 'color', 'length', 'length_unit',
|
||||||
]
|
]
|
||||||
|
widgets = {
|
||||||
|
'status': StaticSelect2,
|
||||||
|
'type': StaticSelect2,
|
||||||
|
'length_unit': StaticSelect2,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ConnectCableToConsolePortForm(ConnectCableToDeviceForm):
|
class ConnectCableToConsolePortForm(ConnectCableToDeviceForm):
|
||||||
@ -3363,6 +3368,11 @@ class CableForm(BootstrapMixin, forms.ModelForm):
|
|||||||
fields = [
|
fields = [
|
||||||
'type', 'status', 'label', 'color', 'length', 'length_unit',
|
'type', 'status', 'label', 'color', 'length', 'length_unit',
|
||||||
]
|
]
|
||||||
|
widgets = {
|
||||||
|
'status': StaticSelect2,
|
||||||
|
'type': StaticSelect2,
|
||||||
|
'length_unit': StaticSelect2,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CableCSVForm(forms.ModelForm):
|
class CableCSVForm(forms.ModelForm):
|
||||||
|
@ -1945,6 +1945,12 @@ class CableCreateView(PermissionRequiredMixin, GetReturnURLMixin, View):
|
|||||||
# Parse initial data manually to avoid setting field values as lists
|
# Parse initial data manually to avoid setting field values as lists
|
||||||
initial_data = {k: request.GET[k] for k in request.GET}
|
initial_data = {k: request.GET[k] for k in request.GET}
|
||||||
|
|
||||||
|
# Set initial site and rack based on side A termination (if not already set)
|
||||||
|
if 'termination_b_site' not in initial_data:
|
||||||
|
initial_data['termination_b_site'] = getattr(self.obj.termination_a.parent, 'site', None)
|
||||||
|
if 'termination_b_rack' not in initial_data:
|
||||||
|
initial_data['termination_b_rack'] = getattr(self.obj.termination_a.parent, 'rack', None)
|
||||||
|
|
||||||
form = self.form_class(instance=self.obj, initial=initial_data)
|
form = self.form_class(instance=self.obj, initial=initial_data)
|
||||||
|
|
||||||
return render(request, self.template_name, {
|
return render(request, self.template_name, {
|
||||||
|
@ -144,25 +144,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4 col-md-offset-4">
|
<div class="col-md-6 col-md-offset-3">
|
||||||
<div class="panel panel-default">
|
{% include 'dcim/inc/cable_form.html' %}
|
||||||
<div class="panel-heading"><strong>Cable</strong></div>
|
|
||||||
<div class="panel-body">
|
|
||||||
{% render_field form.status %}
|
|
||||||
{% render_field form.type %}
|
|
||||||
{% render_field form.label %}
|
|
||||||
{% render_field form.color %}
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-md-3 control-label" for="id_length">{{ form.length.label }}</label>
|
|
||||||
<div class="col-md-6">
|
|
||||||
{{ form.length }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
{{ form.length_unit }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -1,23 +1,5 @@
|
|||||||
{% extends 'utilities/obj_edit.html' %}
|
{% extends 'utilities/obj_edit.html' %}
|
||||||
{% load form_helpers %}
|
|
||||||
|
|
||||||
{% block form %}
|
{% block form %}
|
||||||
<div class="panel panel-default">
|
{% include 'dcim/inc/cable_form.html' %}
|
||||||
<div class="panel-heading"><strong>Cable</strong></div>
|
|
||||||
<div class="panel-body">
|
|
||||||
{% render_field form.type %}
|
|
||||||
{% render_field form.status %}
|
|
||||||
{% render_field form.label %}
|
|
||||||
{% render_field form.color %}
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-md-3 control-label" for="id_length">{{ form.length.label }}</label>
|
|
||||||
<div class="col-md-6">
|
|
||||||
{{ form.length }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
{{ form.length_unit }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
19
netbox/templates/dcim/inc/cable_form.html
Normal file
19
netbox/templates/dcim/inc/cable_form.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{% load form_helpers %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading"><strong>Cable</strong></div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{% render_field form.status %}
|
||||||
|
{% render_field form.type %}
|
||||||
|
{% render_field form.label %}
|
||||||
|
{% render_field form.color %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-3 control-label" for="id_length">{{ form.length.label }}</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
{{ form.length }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form.length_unit }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
Reference in New Issue
Block a user