Skip to content

Commit

Permalink
Fixes #15982: Restore the "assign IP" tab
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed May 7, 2024
1 parent acc2add commit 9316f48
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 51 deletions.
1 change: 1 addition & 0 deletions netbox/ipam/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def get_extra_context(self, request, instance):
class IPAddressEditView(generic.ObjectEditView):
queryset = IPAddress.objects.all()
form = forms.IPAddressForm
template_name = 'ipam/ipaddress_edit.html'

def alter_object(self, obj, request, url_args, url_kwargs):

Expand Down
33 changes: 12 additions & 21 deletions netbox/templates/ipam/inc/ipaddress_edit_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,21 @@

<ul class="nav nav-tabs">
<li class="nav-item">
<a
class="nav-link {% if active_tab == 'add' %}active{% endif %}"
href="{% url 'ipam:ipaddress_add' %}{% querystring request %}"
>
{% if obj.pk %}{% trans "Edit" %}{% else %}{% trans "Create" %}{% endif %}
</a>
<a href="{% url 'ipam:ipaddress_add' %}{% querystring request %}" class="nav-link {% if active_tab == 'add' %}active{% endif %}">
{% if object.pk %}{% trans "Edit" %}{% else %}{% trans "Create" %}{% endif %}
</a>
</li>
{% if 'interface' in request.GET or 'vminterface' in request.GET %}
<li class="nav-item">
<a
class="nav-link {% if active_tab == 'assign' %}active{% endif %}"
href="{% url 'ipam:ipaddress_assign' %}{% querystring request %}"
>
{% trans "Assign IP" %}
<li class="nav-item">
<a href="{% url 'ipam:ipaddress_assign' %}{% querystring request %}" class="nav-link {% if active_tab == 'assign' %}active{% endif %}">
{% trans "Assign IP" %}
</a>
</li>
{% else %}
<li class="nav-item">
<a
class="nav-link {% if active_tab == 'bulk_add' %}active{% endif %}"
href="{% url 'ipam:ipaddress_bulk_add' %}{% querystring request %}"
>
{% trans "Bulk Create" %}
</li>
{% elif not object.pk %}
<li class="nav-item">
<a href="{% url 'ipam:ipaddress_bulk_add' %}{% querystring request %}" class="nav-link {% if active_tab == 'bulk_add' %}active{% endif %}">
{% trans "Bulk Create" %}
</a>
</li>
</li>
{% endif %}
</ul>
56 changes: 26 additions & 30 deletions netbox/templates/ipam/ipaddress_assign.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,33 @@
{% endblock %}

{% block form %}
<form action="{% querystring request %}" method="post" class="form form-horizontal">
{% csrf_token %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
<div class="row mb-3">
<div class="col col-md-8 offset-md-2">
<div class="field-group">
<h6>{% trans "Select IP Address" %}</h6>
{% render_field form.vrf_id %}
{% render_field form.q %}
</div>
</div>
<form action="{% querystring request %}" method="post" class="form form-horizontal">
{% csrf_token %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
<div class="field-group my-5">
<div class="row">
<h5 class="col-9 offset-3">{% trans "Select IP Address" %}</h5>
</div>
{% render_field form.vrf_id %}
{% render_field form.q %}
</div>
<div class="text-end my-3">
<a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
<button type="submit" class="btn btn-primary">{% trans "Search" %}</button>
</div>
</form>
{% if table %}
<div class="row mb-3">
<div class="col col-md-12">
<h3>{% trans "Search Results" %}</h3>
<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>
<div class="row mb-3">
<div class="col col-md-8 offset-md-2 text-end">
<a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
<button type="submit" class="btn btn-primary">{% trans "Search" %}</button>
</div>
</div>
</form>
{% if table %}
<div class="row mb-3">
<div class="col col-md-12">
<h3>{% trans "Search Results" %}</h3>
<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
{% endblock form %}

{% block buttons %}
Expand Down
5 changes: 5 additions & 0 deletions netbox/templates/ipam/ipaddress_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends 'generic/object_edit.html' %}

{% block tabs %}
{% include 'ipam/inc/ipaddress_edit_header.html' with active_tab='add' %}
{% endblock %}

0 comments on commit 9316f48

Please sign in to comment.