From a7ebbf007c52f58090ab808a64bca1684535f309 Mon Sep 17 00:00:00 2001 From: Mencken Davidson <76002183+menckend@users.noreply.github.com> Date: Tue, 22 Oct 2024 07:26:12 -0400 Subject: [PATCH] housekeeping --- docs/index.rst | 4 ++-- netbox_ptov/api/urls.py | 2 ++ netbox_ptov/api/views.py | 2 ++ netbox_ptov/filtersets.py | 8 ++++---- netbox_ptov/migrations/0001_initial.py | 2 +- netbox_ptov/urls.py | 2 -- netbox_ptov/views.py | 22 ++++++++++++++++++++-- 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index eb700ea..e59e2ff 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,9 +2,9 @@ :hidden: Home - Contributing + Contributing :parser: myst_parser.docutils_ - Changelog + Changelog :parser: myst_parser.docutils_ ... autoapi/index diff --git a/netbox_ptov/api/urls.py b/netbox_ptov/api/urls.py index 446697c..60483a2 100644 --- a/netbox_ptov/api/urls.py +++ b/netbox_ptov/api/urls.py @@ -1,3 +1,5 @@ +# api/urls.py + from netbox.api.routers import NetBoxRouter from netbox_ptov.api.views import ( diff --git a/netbox_ptov/api/views.py b/netbox_ptov/api/views.py index 086b19c..5f14865 100644 --- a/netbox_ptov/api/views.py +++ b/netbox_ptov/api/views.py @@ -1,3 +1,5 @@ +# api/views.py + from netbox.api.viewsets import NetBoxModelViewSet from rest_framework.routers import APIRootView diff --git a/netbox_ptov/filtersets.py b/netbox_ptov/filtersets.py index e4d34e5..b03c852 100644 --- a/netbox_ptov/filtersets.py +++ b/netbox_ptov/filtersets.py @@ -2,30 +2,30 @@ from .models import gns3srv, ptovjob, switchtojob - class gns3srvFilterSet(NetBoxModelFilterSet): - class Meta: model = gns3srv fields = ['name', ] + def search(self, queryset, name, value): return queryset.filter(description__icontains=value) -class ptovjobFilterSet(NetBoxModelFilterSet): +class ptovjobFilterSet(NetBoxModelFilterSet): class Meta: model = ptovjob fields = ['name', 'gns3prjname', 'gns3srv', 'eosuname' ] + def search(self, queryset, name, value): return queryset.filter(description__icontains=value) class switchtojobFilterSet(NetBoxModelFilterSet): - class Meta: model = switchtojob fields = ['name', 'switch', 'job' ] + def search(self, queryset, name, value): return queryset.filter(description__icontains=value) diff --git a/netbox_ptov/migrations/0001_initial.py b/netbox_ptov/migrations/0001_initial.py index 28290ac..288cef2 100644 --- a/netbox_ptov/migrations/0001_initial.py +++ b/netbox_ptov/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.9 on 2024-10-21 12:43 +# migrations/0001_initial.py import django.db.models.deletion import taggit.managers diff --git a/netbox_ptov/urls.py b/netbox_ptov/urls.py index 2bf8e46..67cdf42 100644 --- a/netbox_ptov/urls.py +++ b/netbox_ptov/urls.py @@ -5,9 +5,7 @@ urlpatterns = ( -# path("vlab_results/", views.vlab_result, name="vlab_result"), path("golabs/", views.golab, name="golab"), - path("gns3srvs/", views.gns3srvListView.as_view(), name="gns3srv_list"), path("gns3srvs/add/", views.gns3srvEditView.as_view(), name="gns3srv_add"), path("gns3srvs//", views.gns3srvView.as_view(), name="gns3srv"), diff --git a/netbox_ptov/views.py b/netbox_ptov/views.py index 26a72e4..2a5694c 100644 --- a/netbox_ptov/views.py +++ b/netbox_ptov/views.py @@ -1,13 +1,12 @@ from dcnodatg import dcnodatg -# from django.db.models import Count from netbox.views import generic from netbox_ptov import filtersets, forms, models, tables from netbox_ptov.models import gns3srv from django.shortcuts import render, redirect from django.contrib import messages -#from django.forms.models import ConfigContextModelQuerySet import json + def golab(request): if request.method == 'POST': form = forms.golabForm(request.POST) @@ -34,37 +33,56 @@ def golab(request): form = forms.golabForm() return render(request, 'golab.html', {'form': form}) + class gns3srvView(generic.ObjectView): queryset = models.gns3srv.objects.all() + + class gns3srvListView(generic.ObjectListView): queryset = models.gns3srv.objects.all() table = tables.gns3srvTable + + class gns3srvEditView(generic.ObjectEditView): queryset = models.gns3srv.objects.all() form = forms.gns3srvForm + + class gns3srvDeleteView(generic.ObjectDeleteView): queryset = models.gns3srv.objects.all() class ptovjobView(generic.ObjectView): queryset = models.ptovjob.objects.all() + + class ptovjobListView(generic.ObjectListView): queryset = models.ptovjob.objects.all() table = tables.ptovjobTable + + class ptovjobEditView(generic.ObjectEditView): queryset = models.ptovjob.objects.all() form = forms.ptovjobForm + + class ptovjobDeleteView(generic.ObjectDeleteView): queryset = models.ptovjob.objects.all() class switchtojobView(generic.ObjectView): queryset = models.switchtojob.objects.all() + + class switchtojobListView(generic.ObjectListView): queryset = models.switchtojob.objects.all() table = tables.switchtojobTable + + class switchtojobEditView(generic.ObjectEditView): queryset = models.switchtojob.objects.all() form = forms.switchtojobForm + + class switchtojobDeleteView(generic.ObjectDeleteView): queryset = models.switchtojob.objects.all()