14731 cleanup

This commit is contained in:
Arthur Hanson 2024-06-28 10:06:57 -07:00
parent 1a33b280f2
commit 1e26ae79b0
3 changed files with 31 additions and 17 deletions

View File

@ -1,3 +1,5 @@
from datetime import datetime
from django.contrib.humanize.templatetags.humanize import naturalday
import django_tables2 as tables import django_tables2 as tables
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from netbox.tables import BaseTable from netbox.tables import BaseTable
@ -32,3 +34,6 @@ class CertifiedPluginTable(BaseTable):
default_columns = ( default_columns = (
'version', 'last_updated', 'min_version', 'max_version', 'version', 'last_updated', 'min_version', 'max_version',
) )
def render_last_updated(self, value, record):
return naturalday(datetime.fromisoformat(value))

View File

@ -39,6 +39,7 @@ from utilities.query import count_related
from utilities.views import ContentTypePermissionRequiredMixin, GetRelatedModelsMixin, register_model_view from utilities.views import ContentTypePermissionRequiredMixin, GetRelatedModelsMixin, register_model_view
from . import filtersets, forms, tables from . import filtersets, forms, tables
from .models import * from .models import *
from .tables import CertifiedPluginTable
# #
@ -760,6 +761,11 @@ class PluginView(UserPassesTestMixin, View):
plugins = get_catalog_plugins(plugins) plugins = get_catalog_plugins(plugins)
plugin = plugins[name] plugin = plugins[name]
table = CertifiedPluginTable(plugin['versions'], user=request.user)
table.configure(request)
return render(request, 'core/plugin.html', { return render(request, 'core/plugin.html', {
'plugin': plugin, 'plugin': plugin,
'table': table,
}) })

View File

@ -53,32 +53,35 @@ From
{{ plugin.description_short }} {{ plugin.description_short }}
</div> </div>
<div class="tab-pane" id="version-history" role="tabpanel" aria-labelledby="version-history-tab"> <div class="tab-pane" id="version-history" role="tabpanel" aria-labelledby="version-history-tab">
{{ plugin.versions }} <div class="card">
<div class="table-responsive" id="object_list">
{% include 'htmx/table.html' %}
</div>
</div>
</div> </div>
<div class="tab-pane" id="install" role="tabpanel" aria-labelledby="install-tab"> <div class="tab-pane" id="install" role="tabpanel" aria-labelledby="install-tab">
<p>You can install this plugin from the command line with PyPi.</p> <p>You can install this plugin from the command line with PyPi.</p>
<p>The following commands may be helpful; always refer to the plugin's own documentation and the Installing a Plugin unit of the NetBox documentation.</p> <p>The following commands may be helpful; always refer to the plugin's own documentation and the Installing a Plugin unit of the NetBox documentation.</p>
<p>1. Enter the NetBox virtual environment and install the plugin package:</p> <p>1. Enter the NetBox virtual environment and install the plugin package:</p>
<code>
source /opt/netbox/venv/bin/activate<br /> <pre class="block"><code>
source /opt/netbox/venv/bin/activate
pip install netbox-acls pip install netbox-acls
</code> </code></pre>
<p>2. In /opt/netbox/netbox/netbox/configuration.py, add the plugin to the PLUGINS list:</p> <p>2. In /opt/netbox/netbox/netbox/configuration.py, add the plugin to the PLUGINS list:</p>
<code> <pre class="block"><code>
PLUGINS=<br /> PLUGINS=
"netbox_acls',<br /> "netbox_acls',
] ]
</code> </code></pre>
<p>3. Still from the NetBox virtual environment, run database migrations and collect static files:</p> <p>3. Still from the NetBox virtual environment, run database migrations and collect static files:</p>
<code> <pre class="block"><code>
python3<br /> python3 /opt/netbox/netbox/netbox/manage.py migrate
/opt/netbox/netbox/netbox/manage.py migrate<br /> python3 /opt/netbox/netbox/netbox/manage.py collectstatic
pythons<br /> </code></pre>
/opt/netbox/netbox/netbox/manage.py collectstatic
</code>
<p>4. Restart the NetBox services to complete the plugin installation:</p> <p>4. Restart the NetBox services to complete the plugin installation:</p>
<code> <pre class="block"><code>
sudo systemctl restart netbox netbox-rq sudo systemctl restart netbox netbox-rq
</code> </code></pre>
</div> </div>
{% endblock content %} {% endblock content %}