git: d1245d52448d - 2023Q1 - net-mgmt/py-phonebox-plugin: Fix runtime with NetBox 3.3+
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Feb 2023 07:16:42 UTC
The branch 2023Q1 has been updated by kai: URL: https://cgit.FreeBSD.org/ports/commit/?id=d1245d52448dce5562bbe996333288bba693a79e commit d1245d52448dce5562bbe996333288bba693a79e Author: Kai Knoblich <kai@FreeBSD.org> AuthorDate: 2023-02-22 06:53:06 +0000 Commit: Kai Knoblich <kai@FreeBSD.org> CommitDate: 2023-02-22 07:16:21 +0000 net-mgmt/py-phonebox-plugin: Fix runtime with NetBox 3.3+ * Add a workaround as NetBox 3.3 introduced some API changes which break the plugin and since NetBox 3.4 two templates need some modifications as well to work properly. * Bump PORTREVISION due package change. MFH: 2023Q1 (cherry picked from commit 6f053b32fca6ade8b6fb488a085e2a09cc922957) --- net-mgmt/py-phonebox-plugin/Makefile | 1 + .../patch-fix-runtime-with-netbox-3.3-and-later | 187 +++++++++++++++++++++ 2 files changed, 188 insertions(+) diff --git a/net-mgmt/py-phonebox-plugin/Makefile b/net-mgmt/py-phonebox-plugin/Makefile index 188c1f8e83ab..545402ece536 100644 --- a/net-mgmt/py-phonebox-plugin/Makefile +++ b/net-mgmt/py-phonebox-plugin/Makefile @@ -1,5 +1,6 @@ PORTNAME= phonebox-plugin DISTVERSION= 0.0.4b1 +PORTREVISION= 1 CATEGORIES= net-mgmt python MASTER_SITES= CHEESESHOP PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} diff --git a/net-mgmt/py-phonebox-plugin/files/patch-fix-runtime-with-netbox-3.3-and-later b/net-mgmt/py-phonebox-plugin/files/patch-fix-runtime-with-netbox-3.3-and-later new file mode 100644 index 000000000000..b04dd8661c77 --- /dev/null +++ b/net-mgmt/py-phonebox-plugin/files/patch-fix-runtime-with-netbox-3.3-and-later @@ -0,0 +1,187 @@ +Fix runtime issues with NetBox 3.3+ + +See also: + +https://github.com/iDebugAll/phonebox_plugin/issues/27 +https://github.com/iDebugAll/phonebox_plugin/pull/28 + +--- MANIFEST.in.orig 2023-02-21 21:36:03 UTC ++++ MANIFEST.in +@@ -1,4 +1,5 @@ recursive-include phonebox_plugin/templates * + include README.md + include LICENSE + recursive-include phonebox_plugin/templates * ++recursive-exclude phonebox_plugin/templates *.orig .DS_Store + recursive-include phonebox_plugin/static * +--- phonebox_plugin/api/nested_serializers.py.orig 2021-09-21 14:31:12 UTC ++++ phonebox_plugin/api/nested_serializers.py +@@ -1,6 +1,12 @@ from phonebox_plugin import models + from rest_framework import serializers + from phonebox_plugin import models +-from netbox.api import WritableNestedSerializer ++ ++try: ++ from netbox.api import ChoiceField, WritableNestedSerializer ++except ImportError: ++ from netbox.api.fields import ChoiceField ++ from netbox.api.serializers.nested import WritableNestedSerializer ++ + from tenancy.api.nested_serializers import NestedTenantSerializer + + __all__ = ["NestedNumberSerializer", ] +--- phonebox_plugin/templates/phonebox_plugin/list_view_3.4.html.orig 2023-02-21 21:32:23 UTC ++++ phonebox_plugin/templates/phonebox_plugin/list_view_3.4.html +@@ -0,0 +1,62 @@ ++{% extends 'base/layout.html' %} ++{% load buttons %} ++{% load static %} ++{% load plugins %} ++{% load helpers %} ++ ++ ++{% block controls %} ++ ++<div class="pull-right noprint"> ++ {% if perms.phonebox_plugin.add_number %} ++ <a href="/plugins/phonebox/add_number/" type="button" class="btn btn-sm btn-success"> ++ <i class="mdi mdi-plus-thick"></i> Add ++ </a> ++ {% endif %} ++ {% if perms.phonebox_plugin.add_number %} ++ <a href="/plugins/phonebox/import_numbers/" type="button" class="btn btn-sm btn-info"> ++ <i class="mdi mdi-upload"></i> Import ++ </a> ++ {% endif %} ++</div> ++ ++{% endblock %} ++ ++ ++{% block content %} ++ ++<ul class="nav nav-tabs px-3"> ++ <li class="nav-item" role="presentation"> ++ <button class="nav-link active" id="numbers-tab" data-bs-toggle="tab" data-bs-target="#numbers" type="button" role="tab" aria-controls="numbers" aria-selected="true"> ++ Numbers ++ </button> ++ </li> ++ <li class="nav-item" role="presentation"> ++ <button class="nav-link" id="filters-form-tab" data-bs-toggle="tab" data-bs-target="#filters-form" type="button" role="tab" aria-controls="filters-form" aria-selected="false"> ++ Filters ++ {% if filter_form %}{% badge filter_form.changed_data|length %}{% endif %} ++ </button> ++ </li> ++</ul> ++ ++<div class="tab-content"> ++ <div class="tab-pane active" id="numbers" role="tabpanel" aria-labelledby="numbers-tab"> ++ ++ {# Applied filters #} ++ {% if filter_form %} ++ {% applied_filters model filter_form request.GET %} ++ {% endif %} ++ ++ <h2>{% block title %}Numbers{% endblock %}</h2> ++ <div class="row"> ++ <div class="col-md-12"> ++ {% 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> ++ <div class="tab-pane" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab"> ++ {% include 'inc/filter_list.html' %} ++ </div> ++</div> ++ ++{% endblock %} +--- phonebox_plugin/templates/phonebox_plugin/voice_circuit_list_view_3.4.html.orig 2023-02-21 21:32:23 UTC ++++ phonebox_plugin/templates/phonebox_plugin/voice_circuit_list_view_3.4.html +@@ -0,0 +1,62 @@ ++{% extends 'base/layout.html' %} ++{% load buttons %} ++{% load static %} ++{% load plugins %} ++{% load helpers %} ++ ++ ++{% block controls %} ++ ++<div class="pull-right noprint"> ++ {% if perms.phonebox_plugin.add_voice_circuit %} ++ <a href="{% url 'plugins:phonebox_plugin:add_voice_circuit' %}" type="button" class="btn btn-sm btn-success"> ++ <i class="mdi mdi-plus-thick"></i> Add ++ </a> ++ {% endif %} ++ {% if perms.phonebox_plugin.add_voice_circuit %} ++ <a href="{% url 'plugins:phonebox_plugin:import_voice_circuits' %}" type="button" class="btn btn-sm btn-info"> ++ <i class="mdi mdi-upload"></i> Import ++ </a> ++ {% endif %} ++</div> ++ ++{% endblock %} ++ ++ ++{% block content %} ++ ++<ul class="nav nav-tabs px-3"> ++ <li class="nav-item" role="presentation"> ++ <button class="nav-link active" id="voice_circuits-tab" data-bs-toggle="tab" data-bs-target="#voice_circuits" type="button" role="tab" aria-controls="voice_circuits" aria-selected="true"> ++ Voice Circuits ++ </button> ++ </li> ++ <li class="nav-item" role="presentation"> ++ <button class="nav-link" id="filters-form-tab" data-bs-toggle="tab" data-bs-target="#filters-form" type="button" role="tab" aria-controls="filters-form" aria-selected="false"> ++ Filters ++ {% if filter_form %}{% badge filter_form.changed_data|length %}{% endif %} ++ </button> ++ </li> ++</ul> ++ ++<div class="tab-content"> ++ <div class="tab-pane active" id="voice_circuits" role="tabpanel" aria-labelledby="voice_circuits-tab"> ++ ++ {# Applied filters #} ++ {% if filter_form %} ++ {% applied_filters model filter_form request.GET %} ++ {% endif %} ++ ++ <h2>{% block title %}Voice Circuits{% endblock %}</h2> ++ <div class="row"> ++ <div class="col-md-12"> ++ {% 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> ++ <div class="tab-pane" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab"> ++ {% include 'inc/filter_list.html' %} ++ </div> ++</div> ++ ++{% endblock %} +--- phonebox_plugin/views.py.orig 2022-06-09 10:46:13 UTC ++++ phonebox_plugin/views.py +@@ -18,8 +18,10 @@ class NumberListView(generic.ObjectListView): + filterset = filters.NumberFilterSet + filterset_form = forms.NumberFilterForm + table = tables.NumberTable +- if NETBOX_CURRENT_VERSION >= version.parse("3.0"): ++ if NETBOX_CURRENT_VERSION >= version.parse("3.0") and NETBOX_CURRENT_VERSION < version.parse("3.4"): + template_name = "phonebox_plugin/list_view_3.x.html" ++ elif NETBOX_CURRENT_VERSION >= version.parse("3.4"): ++ template_name = "phonebox_plugin/list_view_3.4.html" + else: + template_name = "phonebox_plugin/list_view.html" + +@@ -76,8 +78,10 @@ class VoiceCircuitListView(generic.ObjectListView): + filterset = filters.VoiceCircuitFilterSet + filterset_form = forms.VoiceCircuitFilterForm + table = tables.VoiceCircuitTable +- if NETBOX_CURRENT_VERSION >= version.parse("3.0"): ++ if NETBOX_CURRENT_VERSION >= version.parse("3.0") and NETBOX_CURRENT_VERSION < version.parse("3.4"): + template_name = "phonebox_plugin/voice_circuit_list_view_3.x.html" ++ elif NETBOX_CURRENT_VERSION >= version.parse("3.4"): ++ template_name = "phonebox_plugin/voice_circuit_list_view_3.4.html" + else: + template_name = "phonebox_plugin/voice_circuit_list_view.html" +