Skip to content

Commit

Permalink
Compatibility fix for NetBox 3.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
iDebugAll committed Feb 6, 2022
1 parent 13469a9 commit 86c2e82
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<h2>{% block title %}Numbers{% endblock %}</h2>
<div class="row">
<div class="col-md-12">
{% include 'utilities/obj_table.html' with bulk_delete_url="plugins:phonebox_plugin:number_bulk_delete" bulk_edit_url="plugins:phonebox_plugin:number_bulk_edit" %}
{% include 'phonebox_plugin/obj_table.html' with bulk_delete_url="plugins:phonebox_plugin:number_bulk_delete" bulk_edit_url="plugins:phonebox_plugin:number_bulk_edit" %}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion phonebox_plugin/templates/phonebox_plugin/number_3.x.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h5 class="card-header">
</table>
</div>
</div>
{% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='plugins:phonebox_plugin:list_view' %}
{% include 'phonebox_plugin/tags_panel.html' with tags=object.tags.all url='plugins:phonebox_plugin:list_view' %}
</div>
</div>

Expand Down
62 changes: 62 additions & 0 deletions phonebox_plugin/templates/phonebox_plugin/obj_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{% load helpers %}
{% load render_table from django_tables2 %}

{% if permissions.change or permissions.delete %}
<form method="post" class="form form-horizontal">
{% csrf_token %}
<input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />

{% if table.paginator.num_pages > 1 %}
<div id="select-all-box" class="d-none card noprint">
<div class="card-body">
<div class="float-end">
{% if bulk_edit_url and permissions.change %}
<button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if bulk_querystring %}?{{ bulk_querystring }}{% elif request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm" disabled="disabled">
<span class="mdi mdi-pencil" aria-hidden="true"></span> Edit All
</button>
{% endif %}
{% if bulk_delete_url and permissions.delete %}
<button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if bulk_querystring %}?{{ bulk_querystring }}{% elif request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm" disabled="disabled">
<span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete All
</button>
{% endif %}
</div>
<div class="form-check">
<input type="checkbox" id="select-all" name="_all" class="form-check-input" />
<label for="select-all" class="form-check-label">
Select <strong>all {{ table.objects_count }} {{ table.data.verbose_name_plural }}</strong> matching query
</label>
</div>
</div>
</div>
{% endif %}

<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>

<div class="float-start noprint">
{% block extra_actions %}{% endblock %}

{% if bulk_edit_url and permissions.change %}
<button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
<i class="mdi mdi-pencil" aria-hidden="true"></i> Edit Selected
</button>
{% endif %}

{% if bulk_delete_url and permissions.delete %}
<button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete Selected
</button>
{% endif %}
</div>
</form>
{% else %}

<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>

{% endif %}

{% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
11 changes: 11 additions & 0 deletions phonebox_plugin/templates/phonebox_plugin/tags_panel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% load helpers %}
<div class="card">
<h5 class="card-header">
Tags
</h5>
<div class="card-body">
{% for tag in tags.all %} {% tag tag url %} {% empty %}
<span class="text-muted">No tags assigned</span>
{% endfor %}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h5 class="card-header">
</table>
</div>
</div>
{% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='plugins:phonebox_plugin:voice_circuit_list_view' %}
{% include 'phonebox_plugin/tags_panel.html' with tags=object.tags.all url='plugins:phonebox_plugin:voice_circuit_list_view' %}
</div>
{% if object.voice_circuit_type == "sip_trunk" %}
<div class="col col-md-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<h2>{% block title %}Voice Circuits{% endblock %}</h2>
<div class="row">
<div class="col-md-12">
{% include 'utilities/obj_table.html' with bulk_delete_url="plugins:phonebox_plugin:voice_circuit_bulk_delete" bulk_edit_url="plugins:phonebox_plugin:voice_circuit_bulk_edit" %}
{% include 'phonebox_plugin/obj_table.html' with bulk_delete_url="plugins:phonebox_plugin:voice_circuit_bulk_delete" bulk_edit_url="plugins:phonebox_plugin:voice_circuit_bulk_edit" %}
</div>
</div>
</div>
Expand Down

0 comments on commit 86c2e82

Please sign in to comment.