diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cec5f41..5d92db9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - netbox-version: ["v4.1.8", "v4.2.1"] + netbox-version: ["v4.2.1"] services: redis: image: redis diff --git a/README.md b/README.md index 34b4fb3..271d952 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ support older netbox version as per table below: | 3.7 | 1.6.x | | 4.0 | 2.0.x | | 4.1 | 2.1.x,2.2.x | +| 4.2 | 2.3.x | ## Installing diff --git a/netbox_inventory/__init__.py b/netbox_inventory/__init__.py index 5838576..dc07c25 100644 --- a/netbox_inventory/__init__.py +++ b/netbox_inventory/__init__.py @@ -10,7 +10,7 @@ class NetBoxInventoryConfig(PluginConfig): author = 'Matej Vadnjal' author_email = 'matej.vadnjal@arnes.si' base_url = 'inventory' - min_version = '4.1.0' + min_version = '4.2.1' default_settings = { 'top_level_menu': True, 'used_status_name': 'used', diff --git a/netbox_inventory/navigation.py b/netbox_inventory/navigation.py index db9eea9..2785c6c 100644 --- a/netbox_inventory/navigation.py +++ b/netbox_inventory/navigation.py @@ -9,7 +9,7 @@ permissions=["netbox_inventory.add_asset"], ), PluginMenuButton( - link='plugins:netbox_inventory:asset_import', + link='plugins:netbox_inventory:asset_bulk_import', title='Import', icon_class='mdi mdi-upload', permissions=["netbox_inventory.add_asset"], @@ -24,7 +24,7 @@ permissions=["netbox_inventory.add_supplier"], ), PluginMenuButton( - link='plugins:netbox_inventory:supplier_import', + link='plugins:netbox_inventory:supplier_bulk_import', title='Import', icon_class='mdi mdi-upload', permissions=["netbox_inventory.add_supplier"], @@ -39,7 +39,7 @@ permissions=["netbox_inventory.add_purchase"], ), PluginMenuButton( - link='plugins:netbox_inventory:purchase_import', + link='plugins:netbox_inventory:purchase_bulk_import', title='Import', icon_class='mdi mdi-upload', permissions=["netbox_inventory.add_purchase"], @@ -54,7 +54,7 @@ permissions=["netbox_inventory.add_delivery"], ), PluginMenuButton( - link='plugins:netbox_inventory:delivery_import', + link='plugins:netbox_inventory:delivery_bulk_import', title='Import', icon_class='mdi mdi-upload', permissions=["netbox_inventory.add_delivery"], @@ -69,7 +69,7 @@ permissions=["netbox_inventory.add_inventoryitemtype"], ), PluginMenuButton( - link='plugins:netbox_inventory:inventoryitemtype_import', + link='plugins:netbox_inventory:inventoryitemtype_bulk_import', title='Import', icon_class='mdi mdi-upload', permissions=["netbox_inventory.add_inventoryitemtype"], @@ -84,7 +84,7 @@ permissions=["netbox_inventory.add_inventoryitemgroup"], ), PluginMenuButton( - link='plugins:netbox_inventory:inventoryitemgroup_import', + link='plugins:netbox_inventory:inventoryitemgroup_bulk_import', title='Import', icon_class='mdi mdi-upload', permissions=["netbox_inventory.add_inventoryitemgroup"], diff --git a/netbox_inventory/template_content.py b/netbox_inventory/template_content.py index 2edb5b6..7742ce5 100644 --- a/netbox_inventory/template_content.py +++ b/netbox_inventory/template_content.py @@ -93,27 +93,27 @@ def right_page(self): class DeviceAssetInfo(AssetInfoExtension): - model = 'dcim.device' + models = ['dcim.device'] kind = 'device' class ModuleAssetInfo(AssetInfoExtension): - model = 'dcim.module' + models = ['dcim.module'] kind = 'module' class InventoryItemAssetInfo(AssetInfoExtension): - model = 'dcim.inventoryitem' + models = ['dcim.inventoryitem'] kind = 'inventoryitem' class RackAssetInfo(AssetInfoExtension): - model = 'dcim.rack' + models = ['dcim.rack'] kind = 'rack' class ManufacturerAssetCounts(PluginTemplateExtension): - model = 'dcim.manufacturer' + models = ['dcim.manufacturer'] def right_page(self): object = self.context.get('object') user = self.context['request'].user @@ -151,18 +151,18 @@ def right_page(self): class SiteAssetCounts(AssetLocationCounts): - model = 'dcim.site' + models = ['dcim.site'] location_type='site' class LocationAssetCounts(AssetLocationCounts): - model = 'dcim.location' + models = ['dcim.location'] location_type='location' class RackAssetCounts(PluginTemplateExtension): # rack cannot have stored assets so we can't use AssetLocationStats - model = 'dcim.rack' + models = ['dcim.rack'] def right_page(self): object = self.context.get('object') user = self.context['request'].user @@ -181,7 +181,7 @@ def right_page(self): class TenantAssetCounts(PluginTemplateExtension): - model = 'tenancy.tenant' + models = ['tenancy.tenant'] def right_page(self): object = self.context.get('object') user = self.context['request'].user @@ -203,7 +203,7 @@ def right_page(self): class ContactAssetCounts(PluginTemplateExtension): - model = 'tenancy.contact' + models = ['tenancy.contact'] def right_page(self): object = self.context.get('object') user = self.context['request'].user diff --git a/netbox_inventory/templates/netbox_inventory/supplier.html b/netbox_inventory/templates/netbox_inventory/supplier.html index d5775a7..a2c68a5 100644 --- a/netbox_inventory/templates/netbox_inventory/supplier.html +++ b/netbox_inventory/templates/netbox_inventory/supplier.html @@ -64,4 +64,5 @@
Supplied Assets
{% plugin_full_width_page object %} + {% endblock content %} diff --git a/netbox_inventory/tests/asset/test_views_create.py b/netbox_inventory/tests/asset/test_views_create.py index 6dee273..6e040b1 100644 --- a/netbox_inventory/tests/asset/test_views_create.py +++ b/netbox_inventory/tests/asset/test_views_create.py @@ -181,6 +181,7 @@ def setUp(self): self.form_data = { 'device': self.device1.pk, 'name': 'inventoryitem1', + 'status': 'active', } self.tested_asset = self.asset_inventoryitem_sn @@ -248,6 +249,7 @@ def setUp(self): self.form_data = { 'device': self.device1.pk, 'name': 'inventoryitem1', + 'status': 'active', } self.tested_asset = self.asset_inventoryitem_no diff --git a/netbox_inventory/tests/test_load.py b/netbox_inventory/tests/test_load.py index 88ca6f2..937da2c 100644 --- a/netbox_inventory/tests/test_load.py +++ b/netbox_inventory/tests/test_load.py @@ -11,7 +11,7 @@ class NetboxInventoryVersionTestCase(SimpleTestCase): """ def test_version(self): - assert __version__ == "2.2.1" + assert __version__ == "2.3.0" class AppTest(APITestCase): diff --git a/netbox_inventory/urls.py b/netbox_inventory/urls.py index 0759839..147d621 100644 --- a/netbox_inventory/urls.py +++ b/netbox_inventory/urls.py @@ -1,24 +1,14 @@ from django.urls import include, path -from netbox.views.generic import ObjectChangeLogView, ObjectJournalView from utilities.urls import get_model_urls -from . import models, views +from . import views urlpatterns = ( # Assets - path('assets/', views.AssetListView.as_view(), name='asset_list'), - path('assets/add/', views.AssetEditView.as_view(), name='asset_add'), - path('assets/bulk-add/', views.AssetBulkCreateView.as_view(), name='asset_bulk_add'), - path('assets/import/', views.AssetBulkImportView.as_view(), name='asset_import'), - path('assets/edit/', views.AssetBulkEditView.as_view(), name='asset_bulk_edit'), - path('assets/delete/', views.AssetBulkDeleteView.as_view(), name='asset_bulk_delete'), - path('assets/', views.AssetView.as_view(), name='asset'), - path('assets//edit/', views.AssetEditView.as_view(), name='asset_edit'), - path('assets//delete/', views.AssetDeleteView.as_view(), name='asset_delete'), - path('assets//changelog/', ObjectChangeLogView.as_view(), name='asset_changelog', kwargs={'model': models.Asset}), - path('assets//journal/', ObjectJournalView.as_view(), name='asset_journal', kwargs={'model': models.Asset}), + path('assets/', include(get_model_urls('netbox_inventory', 'asset', detail=False))), + path('assets//', include(get_model_urls('netbox_inventory', 'asset'))), path('assets//assign/', views.AssetAssignView.as_view(), name='asset_assign'), path('assets/device/create/', views.AssetDeviceCreateView.as_view(), name='asset_device_create'), path('assets/module/create/', views.AssetModuleCreateView.as_view(), name='asset_module_create'), @@ -30,58 +20,23 @@ path('assets/rack//reassign/', views.AssetRackReassignView.as_view(), name='asset_rack_reassign'), # Suppliers - path('suppliers/', views.SupplierListView.as_view(), name='supplier_list'), - path('suppliers/add/', views.SupplierEditView.as_view(), name='supplier_add'), - path('suppliers/import/', views.SupplierBulkImportView.as_view(), name='supplier_import'), - path('suppliers/edit/', views.SupplierBulkEditView.as_view(), name='supplier_bulk_edit'), - path('suppliers/delete/', views.SupplierBulkDeleteView.as_view(), name='supplier_bulk_delete'), - path('suppliers/', views.SupplierView.as_view(), name='supplier'), + path('suppliers/', include(get_model_urls('netbox_inventory', 'supplier', detail=False))), path('suppliers//', include(get_model_urls('netbox_inventory', 'supplier'))), # Purchases - path('purchases/', views.PurchaseListView.as_view(), name='purchase_list'), - path('purchases/add/', views.PurchaseEditView.as_view(), name='purchase_add'), - path('purchases/import/', views.PurchaseBulkImportView.as_view(), name='purchase_import'), - path('purchases/edit/', views.PurchaseBulkEditView.as_view(), name='purchase_bulk_edit'), - path('purchases/delete/', views.PurchaseBulkDeleteView.as_view(), name='purchase_bulk_delete'), - path('purchases/', views.PurchaseView.as_view(), name='purchase'), - path('purchases//edit/', views.PurchaseEditView.as_view(), name='purchase_edit'), - path('purchases//delete/', views.PurchaseDeleteView.as_view(), name='purchase_delete'), - path('purchases//changelog/', ObjectChangeLogView.as_view(), name='purchase_changelog', kwargs={'model': models.Purchase}), - path('purchases//journal/', ObjectJournalView.as_view(), name='purchase_journal', kwargs={'model': models.Purchase}), + path('purchases/', include(get_model_urls('netbox_inventory', 'purchase', detail=False))), + path('purchases//', include(get_model_urls('netbox_inventory', 'purchase'))), # Deliveries - path('deliveries/', views.DeliveryListView.as_view(), name='delivery_list'), - path('deliveries/add/', views.DeliveryEditView.as_view(), name='delivery_add'), - path('deliveries/import/', views.DeliveryBulkImportView.as_view(), name='delivery_import'), - path('deliveries/edit/', views.DeliveryBulkEditView.as_view(), name='delivery_bulk_edit'), - path('deliveries/delete/', views.DeliveryBulkDeleteView.as_view(), name='delivery_bulk_delete'), - path('deliveries/', views.DeliveryView.as_view(), name='delivery'), - path('deliveries//edit/', views.DeliveryEditView.as_view(), name='delivery_edit'), - path('deliveries//delete/', views.DeliveryDeleteView.as_view(), name='delivery_delete'), - path('deliveries//changelog/', ObjectChangeLogView.as_view(), name='delivery_changelog', kwargs={'model': models.Delivery}), - path('deliveries//journal/', ObjectJournalView.as_view(), name='delivery_journal', kwargs={'model': models.Delivery}), + path('deliveries/', include(get_model_urls('netbox_inventory', 'delivery', detail=False))), + path('deliveries//', include(get_model_urls('netbox_inventory', 'delivery'))), # InventoryItemTypes - path('inventory-item-types/', views.InventoryItemTypeListView.as_view(), name='inventoryitemtype_list'), - path('inventory-item-types/add/', views.InventoryItemTypeEditView.as_view(), name='inventoryitemtype_add'), - path('inventory-item-types/import/', views.InventoryItemTypeBulkImportView.as_view(), name='inventoryitemtype_import'), - path('inventory-item-types/edit/', views.InventoryItemTypeBulkEditView.as_view(), name='inventoryitemtype_bulk_edit'), - path('inventory-item-types/delete/', views.InventoryItemTypeBulkDeleteView.as_view(), name='inventoryitemtype_bulk_delete'), - path('inventory-item-types/', views.InventoryItemTypeView.as_view(), name='inventoryitemtype'), - path('inventory-item-types//edit/', views.InventoryItemTypeEditView.as_view(), name='inventoryitemtype_edit'), - path('inventory-item-types//delete/', views.InventoryItemTypeDeleteView.as_view(), name='inventoryitemtype_delete'), - path('inventory-item-types//changelog/', ObjectChangeLogView.as_view(), name='inventoryitemtype_changelog', kwargs={'model': models.InventoryItemType}), + path('inventory-item-types/', include(get_model_urls('netbox_inventory', 'inventoryitemtype', detail=False))), + path('inventory-item-types//', include(get_model_urls('netbox_inventory', 'inventoryitemtype'))), # InventoryItemGroups - path('inventory-item-groups/', views.InventoryItemGroupListView.as_view(), name='inventoryitemgroup_list'), - path('inventory-item-groups/add/', views.InventoryItemGroupEditView.as_view(), name='inventoryitemgroup_add'), - path('inventory-item-groups/import/', views.InventoryItemGroupBulkImportView.as_view(), name='inventoryitemgroup_import'), - path('inventory-item-groups/edit/', views.InventoryItemGroupBulkEditView.as_view(), name='inventoryitemgroup_bulk_edit'), - path('inventory-item-groups/delete/', views.InventoryItemGroupBulkDeleteView.as_view(), name='inventoryitemgroup_bulk_delete'), - path('inventory-item-groups/', views.InventoryItemGroupView.as_view(), name='inventoryitemgroup'), - path('inventory-item-groups//edit/', views.InventoryItemGroupEditView.as_view(), name='inventoryitemgroup_edit'), - path('inventory-item-groups//delete/', views.InventoryItemGroupDeleteView.as_view(), name='inventoryitemgroup_delete'), - path('inventory-item-groups//changelog/', ObjectChangeLogView.as_view(), name='inventoryitemgroup_changelog', kwargs={'model': models.InventoryItemGroup}), + path('inventory-item-groups/', include(get_model_urls('netbox_inventory', 'inventoryitemgroup', detail=False))), + path('inventory-item-groups//', include(get_model_urls('netbox_inventory', 'inventoryitemgroup'))), ) diff --git a/netbox_inventory/version.py b/netbox_inventory/version.py index 36a511e..8219039 100644 --- a/netbox_inventory/version.py +++ b/netbox_inventory/version.py @@ -1 +1 @@ -__version__ = '2.2.1' +__version__ = '2.3.0' diff --git a/netbox_inventory/views/asset.py b/netbox_inventory/views/asset.py index 0f88d57..3f932a4 100644 --- a/netbox_inventory/views/asset.py +++ b/netbox_inventory/views/asset.py @@ -6,6 +6,7 @@ from django.template import Template from netbox.views import generic from utilities.forms import ConfirmationForm, restrict_form_fields +from utilities.views import register_model_view from .. import filtersets, forms, models, tables from ..template_content import WARRANTY_PROGRESSBAR @@ -26,6 +27,7 @@ ) +@register_model_view(models.Asset) class AssetView(generic.ObjectView): queryset = models.Asset.objects.all() @@ -35,6 +37,7 @@ def get_extra_context(self, request, instance): return context +@register_model_view(models.Asset, 'list', path='', detail=False) class AssetListView(generic.ObjectListView): queryset = models.Asset.objects.prefetch_related( 'device_type__manufacturer', @@ -56,6 +59,7 @@ class AssetListView(generic.ObjectListView): filterset_form = forms.AssetFilterForm +@register_model_view(models.Asset, 'bulk_add', path='bulk-add', detail=False) class AssetBulkCreateView(generic.BulkCreateView): queryset = models.Asset.objects.all() form = forms.AssetBulkAddForm @@ -82,12 +86,15 @@ def _create_objects(self, form, request): return new_objects +@register_model_view(models.Asset, 'edit') +@register_model_view(models.Asset, 'add', detail=False) class AssetEditView(generic.ObjectEditView): queryset = models.Asset.objects.all() form = forms.AssetForm template_name = 'netbox_inventory/asset_edit.html' +@register_model_view(models.Asset, 'delete') class AssetDeleteView(generic.ObjectDeleteView): queryset = models.Asset.objects.all() @@ -117,12 +124,14 @@ def post(self, request, *args, **kwargs): return super().post(request, *args, **kwargs) +@register_model_view(models.Asset, 'bulk_import', path='import', detail=False) class AssetBulkImportView(generic.BulkImportView): queryset = models.Asset.objects.all() model_form = forms.AssetImportForm template_name = 'netbox_inventory/asset_bulk_import.html' +@register_model_view(models.Asset, 'bulk_edit', path='edit', detail=False) class AssetBulkEditView(generic.BulkEditView): queryset = models.Asset.objects.all() filterset = filtersets.AssetFilterSet @@ -198,6 +207,7 @@ def post(self, request, **kwargs): return super().post(request, **kwargs) +@register_model_view(models.Asset, 'bulk_delete', path='delete', detail=False) class AssetBulkDeleteView(generic.BulkDeleteView): queryset = models.Asset.objects.all() table = tables.AssetTable diff --git a/netbox_inventory/views/delivery.py b/netbox_inventory/views/delivery.py index 337365f..3d9765f 100644 --- a/netbox_inventory/views/delivery.py +++ b/netbox_inventory/views/delivery.py @@ -1,5 +1,6 @@ from netbox.views import generic from utilities.query import count_related +from utilities.views import register_model_view from .. import filtersets, forms, models, tables __all__ = ( @@ -12,6 +13,8 @@ 'DeliveryBulkDeleteView', ) + +@register_model_view(models.Delivery) class DeliveryView(generic.ObjectView): queryset = models.Delivery.objects.all() @@ -21,6 +24,7 @@ def get_extra_context(self, request, instance): } +@register_model_view(models.Delivery, 'list', path='', detail=False) class DeliveryListView(generic.ObjectListView): queryset = models.Delivery.objects.annotate( asset_count=count_related(models.Asset, 'delivery'), @@ -30,20 +34,25 @@ class DeliveryListView(generic.ObjectListView): filterset_form = forms.DeliveryFilterForm +@register_model_view(models.Delivery, 'edit') +@register_model_view(models.Delivery, 'add', detail=False) class DeliveryEditView(generic.ObjectEditView): queryset = models.Delivery.objects.all() form = forms.DeliveryForm +@register_model_view(models.Delivery, 'delete') class DeliveryDeleteView(generic.ObjectDeleteView): queryset = models.Delivery.objects.all() +@register_model_view(models.Delivery, 'bulk_import', path='import', detail=False) class DeliveryBulkImportView(generic.BulkImportView): queryset = models.Delivery.objects.all() model_form = forms.DeliveryImportForm +@register_model_view(models.Delivery, 'bulk_edit', path='edit', detail=False) class DeliveryBulkEditView(generic.BulkEditView): queryset = models.Delivery.objects.all() filterset = filtersets.DeliveryFilterSet @@ -51,6 +60,7 @@ class DeliveryBulkEditView(generic.BulkEditView): form = forms.DeliveryBulkEditForm +@register_model_view(models.Delivery, 'bulk_delete', path='delete', detail=False) class DeliveryBulkDeleteView(generic.BulkDeleteView): queryset = models.Delivery.objects.all() table = tables.DeliveryTable diff --git a/netbox_inventory/views/inventoryitem_group.py b/netbox_inventory/views/inventoryitem_group.py index 84d52e0..8c7c24e 100644 --- a/netbox_inventory/views/inventoryitem_group.py +++ b/netbox_inventory/views/inventoryitem_group.py @@ -1,4 +1,5 @@ from netbox.views import generic +from utilities.views import register_model_view from .. import filtersets, forms, models, tables from ..choices import AssetStatusChoices @@ -15,6 +16,7 @@ ) +@register_model_view(models.InventoryItemGroup) class InventoryItemGroupView(generic.ObjectView): queryset = models.InventoryItemGroup.objects.all() @@ -97,6 +99,7 @@ def get_extra_context(self, request, instance): } +@register_model_view(models.InventoryItemGroup, 'list', path='', detail=False) class InventoryItemGroupListView(generic.ObjectListView): queryset = models.InventoryItemGroup.objects.add_related_count( models.InventoryItemGroup.objects.all(), @@ -117,20 +120,25 @@ class InventoryItemGroupListView(generic.ObjectListView): filterset_form = forms.InventoryItemGroupFilterForm +@register_model_view(models.InventoryItemGroup, 'edit') +@register_model_view(models.InventoryItemGroup, 'add', detail=False) class InventoryItemGroupEditView(generic.ObjectEditView): queryset = models.InventoryItemGroup.objects.all() form = forms.InventoryItemGroupForm +@register_model_view(models.InventoryItemGroup, 'delete') class InventoryItemGroupDeleteView(generic.ObjectDeleteView): queryset = models.InventoryItemGroup.objects.all() +@register_model_view(models.InventoryItemGroup, 'bulk_import', path='import', detail=False) class InventoryItemGroupBulkImportView(generic.BulkImportView): queryset = models.InventoryItemGroup.objects.all() model_form = forms.InventoryItemGroupImportForm +@register_model_view(models.InventoryItemGroup, 'bulk_edit', path='edit', detail=False) class InventoryItemGroupBulkEditView(generic.BulkEditView): queryset = models.InventoryItemGroup.objects.all() filterset = filtersets.InventoryItemGroupFilterSet @@ -138,6 +146,7 @@ class InventoryItemGroupBulkEditView(generic.BulkEditView): form = forms.InventoryItemGroupBulkEditForm +@register_model_view(models.InventoryItemGroup, 'bulk_delete', path='delete', detail=False) class InventoryItemGroupBulkDeleteView(generic.BulkDeleteView): queryset = models.InventoryItemGroup.objects.all() table = tables.InventoryItemGroupTable diff --git a/netbox_inventory/views/inventoryitem_type.py b/netbox_inventory/views/inventoryitem_type.py index 720463d..e1b0430 100644 --- a/netbox_inventory/views/inventoryitem_type.py +++ b/netbox_inventory/views/inventoryitem_type.py @@ -1,5 +1,6 @@ from netbox.views import generic from utilities.query import count_related +from utilities.views import register_model_view from .. import filtersets, forms, models, tables __all__ = ( @@ -12,6 +13,8 @@ 'InventoryItemTypeBulkDeleteView', ) + +@register_model_view(models.InventoryItemType) class InventoryItemTypeView(generic.ObjectView): queryset = models.InventoryItemType.objects.all() @@ -21,6 +24,7 @@ def get_extra_context(self, request, instance): return context +@register_model_view(models.InventoryItemType, 'list', path='', detail=False) class InventoryItemTypeListView(generic.ObjectListView): queryset = models.InventoryItemType.objects.annotate( asset_count=count_related(models.Asset, 'inventoryitem_type'), @@ -30,20 +34,25 @@ class InventoryItemTypeListView(generic.ObjectListView): filterset_form = forms.InventoryItemTypeFilterForm +@register_model_view(models.InventoryItemType, 'edit') +@register_model_view(models.InventoryItemType, 'add', detail=False) class InventoryItemTypeEditView(generic.ObjectEditView): queryset = models.InventoryItemType.objects.all() form = forms.InventoryItemTypeForm +@register_model_view(models.InventoryItemType, 'delete') class InventoryItemTypeDeleteView(generic.ObjectDeleteView): queryset = models.InventoryItemType.objects.all() +@register_model_view(models.InventoryItemType, 'bulk_import', path='import', detail=False) class InventoryItemTypeBulkImportView(generic.BulkImportView): queryset = models.InventoryItemType.objects.all() model_form = forms.InventoryItemTypeImportForm +@register_model_view(models.InventoryItemType, 'bulk_edit', path='edit', detail=False) class InventoryItemTypeBulkEditView(generic.BulkEditView): queryset = models.InventoryItemType.objects.all() filterset = filtersets.InventoryItemTypeFilterSet @@ -51,6 +60,7 @@ class InventoryItemTypeBulkEditView(generic.BulkEditView): form = forms.InventoryItemTypeBulkEditForm +@register_model_view(models.InventoryItemType, 'bulk_delete', path='delete', detail=False) class InventoryItemTypeBulkDeleteView(generic.BulkDeleteView): queryset = models.InventoryItemType.objects.all() table = tables.InventoryItemTypeTable diff --git a/netbox_inventory/views/purchase.py b/netbox_inventory/views/purchase.py index 64d5223..ed67f1c 100644 --- a/netbox_inventory/views/purchase.py +++ b/netbox_inventory/views/purchase.py @@ -1,5 +1,6 @@ from netbox.views import generic from utilities.query import count_related +from utilities.views import register_model_view from .. import filtersets, forms, models, tables __all__ = ( @@ -12,6 +13,8 @@ 'PurchaseBulkDeleteView', ) + +@register_model_view(models.Purchase) class PurchaseView(generic.ObjectView): queryset = models.Purchase.objects.all() @@ -21,6 +24,8 @@ def get_extra_context(self, request, instance): 'delivery_count': models.Delivery.objects.filter(purchase=instance).count(), } + +@register_model_view(models.Purchase, 'list', path='', detail=False) class PurchaseListView(generic.ObjectListView): queryset = models.Purchase.objects.annotate( asset_count=count_related(models.Asset, 'purchase'), @@ -31,20 +36,25 @@ class PurchaseListView(generic.ObjectListView): filterset_form = forms.PurchaseFilterForm +@register_model_view(models.Purchase, 'edit') +@register_model_view(models.Purchase, 'add', detail=False) class PurchaseEditView(generic.ObjectEditView): queryset = models.Purchase.objects.all() form = forms.PurchaseForm +@register_model_view(models.Purchase, 'delete') class PurchaseDeleteView(generic.ObjectDeleteView): queryset = models.Purchase.objects.all() +@register_model_view(models.Purchase, 'bulk_import', path='import', detail=False) class PurchaseBulkImportView(generic.BulkImportView): queryset = models.Purchase.objects.all() model_form = forms.PurchaseImportForm +@register_model_view(models.Purchase, 'bulk_edit', path='edit', detail=False) class PurchaseBulkEditView(generic.BulkEditView): queryset = models.Purchase.objects.all() filterset = filtersets.PurchaseFilterSet @@ -52,6 +62,7 @@ class PurchaseBulkEditView(generic.BulkEditView): form = forms.PurchaseBulkEditForm +@register_model_view(models.Purchase, 'bulk_delete', path='delete', detail=False) class PurchaseBulkDeleteView(generic.BulkDeleteView): queryset = models.Purchase.objects.all() table = tables.PurchaseTable diff --git a/netbox_inventory/views/supplier.py b/netbox_inventory/views/supplier.py index 1227b3a..bd15bb1 100644 --- a/netbox_inventory/views/supplier.py +++ b/netbox_inventory/views/supplier.py @@ -16,6 +16,7 @@ ) +@register_model_view(models.Supplier) class SupplierView(generic.ObjectView): queryset = models.Supplier.objects.all() @@ -27,6 +28,7 @@ def get_extra_context(self, request, instance): } +@register_model_view(models.Supplier, 'list', path='', detail=False) class SupplierListView(generic.ObjectListView): queryset = models.Supplier.objects.annotate( purchase_count=count_related(models.Purchase, 'supplier'), @@ -39,6 +41,7 @@ class SupplierListView(generic.ObjectListView): @register_model_view(models.Supplier, 'edit') +@register_model_view(models.Supplier, 'add', detail=False) class SupplierEditView(generic.ObjectEditView): queryset = models.Supplier.objects.all() form = forms.SupplierForm @@ -49,11 +52,13 @@ class SupplierDeleteView(generic.ObjectDeleteView): queryset = models.Supplier.objects.all() +@register_model_view(models.Supplier, 'bulk_import', path='import', detail=False) class SupplierBulkImportView(generic.BulkImportView): queryset = models.Supplier.objects.all() model_form = forms.SupplierImportForm +@register_model_view(models.Supplier, 'bulk_edit', path='edit', detail=False) class SupplierBulkEditView(generic.BulkEditView): queryset = models.Supplier.objects.all() filterset = filtersets.SupplierFilterSet @@ -61,6 +66,7 @@ class SupplierBulkEditView(generic.BulkEditView): form = forms.SupplierBulkEditForm +@register_model_view(models.Supplier, 'bulk_delete', path='delete', detail=False) class SupplierBulkDeleteView(generic.BulkDeleteView): queryset = models.Supplier.objects.all() table = tables.SupplierTable diff --git a/pyproject.toml b/pyproject.toml index 4bc2286..5c5a6a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-inventory" -version = "2.2.1" +version = "2.3.0" authors = [ { name="Matej Vadnjal", email="matej.vadnjal@arnes.si" }, ]