mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-18 19:32:24 -06:00
* Enable bulk editing of organizational models * Enable bulk editing of nested group models * Changelog for #5972
This commit is contained in:
@@ -44,6 +44,24 @@ class TenantGroupCSVForm(CustomFieldModelCSVForm):
|
||||
fields = TenantGroup.csv_headers
|
||||
|
||||
|
||||
class TenantGroupBulkEditForm(BootstrapMixin, CustomFieldBulkEditForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=TenantGroup.objects.all(),
|
||||
widget=forms.MultipleHiddenInput
|
||||
)
|
||||
parent = DynamicModelChoiceField(
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
description = forms.CharField(
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
|
||||
class Meta:
|
||||
nullable_fields = ['parent', 'description']
|
||||
|
||||
|
||||
#
|
||||
# Tenants
|
||||
#
|
||||
|
||||
@@ -29,6 +29,10 @@ class TenantGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
||||
"Tenant Group 6,tenant-group-6,Sixth tenant group",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
class TenantTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
model = Tenant
|
||||
|
||||
@@ -11,6 +11,7 @@ urlpatterns = [
|
||||
path('tenant-groups/', views.TenantGroupListView.as_view(), name='tenantgroup_list'),
|
||||
path('tenant-groups/add/', views.TenantGroupEditView.as_view(), name='tenantgroup_add'),
|
||||
path('tenant-groups/import/', views.TenantGroupBulkImportView.as_view(), name='tenantgroup_import'),
|
||||
path('tenant-groups/edit/', views.TenantGroupBulkEditView.as_view(), name='tenantgroup_bulk_edit'),
|
||||
path('tenant-groups/delete/', views.TenantGroupBulkDeleteView.as_view(), name='tenantgroup_bulk_delete'),
|
||||
path('tenant-groups/<int:pk>/edit/', views.TenantGroupEditView.as_view(), name='tenantgroup_edit'),
|
||||
path('tenant-groups/<int:pk>/delete/', views.TenantGroupDeleteView.as_view(), name='tenantgroup_delete'),
|
||||
|
||||
@@ -39,6 +39,19 @@ class TenantGroupBulkImportView(generic.BulkImportView):
|
||||
table = tables.TenantGroupTable
|
||||
|
||||
|
||||
class TenantGroupBulkEditView(generic.BulkEditView):
|
||||
queryset = TenantGroup.objects.add_related_count(
|
||||
TenantGroup.objects.all(),
|
||||
Tenant,
|
||||
'group',
|
||||
'tenant_count',
|
||||
cumulative=True
|
||||
)
|
||||
filterset = filters.TenantGroupFilterSet
|
||||
table = tables.TenantGroupTable
|
||||
form = forms.TenantGroupBulkEditForm
|
||||
|
||||
|
||||
class TenantGroupBulkDeleteView(generic.BulkDeleteView):
|
||||
queryset = TenantGroup.objects.add_related_count(
|
||||
TenantGroup.objects.all(),
|
||||
|
||||
Reference in New Issue
Block a user