Skip to content

Commit

Permalink
Closes #10242: Redirect to filtered objects list after bulk import (#…
Browse files Browse the repository at this point in the history
…12001)

* Redirect user to filtered objects list after bulk import

* Remove obsolete table attribute from bulk import views
  • Loading branch information
jeremystretch authored Mar 17, 2023
1 parent 6e4c4c4 commit 206d578
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 108 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/version-3.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ A new ASN range model has been introduced to facilitate the provisioning of new
* [#9073](https://github.com/netbox-community/netbox/issues/9073) - Enable syncing config context data from remote sources
* [#9653](https://github.com/netbox-community/netbox/issues/9653) - Enable setting a default platform for device types
* [#10054](https://github.com/netbox-community/netbox/issues/10054) - Introduce advanced object selector for UI forms
* [#10242](https://github.com/netbox-community/netbox/issues/10242) - Redirect to filter objects list after bulk import
* [#10374](https://github.com/netbox-community/netbox/issues/10374) - Require unique tenant names & slugs per group (not globally)
* [#10729](https://github.com/netbox-community/netbox/issues/10729) - Add date & time custom field type
* [#11254](https://github.com/netbox-community/netbox/issues/11254) - Introduce the `X-Request-ID` HTTP header to annotate the unique ID of each request for change logging
Expand Down
4 changes: 0 additions & 4 deletions netbox/circuits/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ProviderDeleteView(generic.ObjectDeleteView):
class ProviderBulkImportView(generic.BulkImportView):
queryset = Provider.objects.all()
model_form = forms.ProviderImportForm
table = tables.ProviderTable


class ProviderBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -115,7 +114,6 @@ class ProviderNetworkDeleteView(generic.ObjectDeleteView):
class ProviderNetworkBulkImportView(generic.BulkImportView):
queryset = ProviderNetwork.objects.all()
model_form = forms.ProviderNetworkImportForm
table = tables.ProviderNetworkTable


class ProviderNetworkBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -172,7 +170,6 @@ class CircuitTypeDeleteView(generic.ObjectDeleteView):
class CircuitTypeBulkImportView(generic.BulkImportView):
queryset = CircuitType.objects.all()
model_form = forms.CircuitTypeImportForm
table = tables.CircuitTypeTable


class CircuitTypeBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -224,7 +221,6 @@ class CircuitDeleteView(generic.ObjectDeleteView):
class CircuitBulkImportView(generic.BulkImportView):
queryset = Circuit.objects.all()
model_form = forms.CircuitImportForm
table = tables.CircuitTable
additional_permissions = [
'circuits.add_circuittermination',
]
Expand Down
1 change: 0 additions & 1 deletion netbox/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class DataSourceDeleteView(generic.ObjectDeleteView):
class DataSourceBulkImportView(generic.BulkImportView):
queryset = DataSource.objects.all()
model_form = forms.DataSourceImportForm
table = tables.DataSourceTable


class DataSourceBulkEditView(generic.BulkEditView):
Expand Down
6 changes: 3 additions & 3 deletions netbox/dcim/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,7 @@ def test_module_bulk_replication(self):
}

initial_count = Module.objects.count()
self.assertHttpStatus(self.client.post(**request), 200)
self.assertHttpStatus(self.client.post(**request), 302)
self.assertEqual(Module.objects.count(), initial_count + len(csv_data) - 1)
self.assertEqual(Interface.objects.filter(device=device).count(), 0)

Expand All @@ -2010,7 +2010,7 @@ def test_module_bulk_replication(self):
}

initial_count = Module.objects.count()
self.assertHttpStatus(self.client.post(**request), 200)
self.assertHttpStatus(self.client.post(**request), 302)
self.assertEqual(Module.objects.count(), initial_count + len(csv_data) - 1)
self.assertEqual(Interface.objects.filter(device=device).count(), 5)

Expand Down Expand Up @@ -2086,7 +2086,7 @@ def test_module_bulk_adoption(self):
}

initial_count = self._get_queryset().count()
self.assertHttpStatus(self.client.post(**request), 200)
self.assertHttpStatus(self.client.post(**request), 302)
self.assertEqual(self._get_queryset().count(), initial_count + len(csv_data) - 1)

# Re-retrieve interface to get new module id
Expand Down
31 changes: 0 additions & 31 deletions netbox/dcim/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from virtualization.models import VirtualMachine
from . import filtersets, forms, tables
from .choices import DeviceFaceChoices
from .constants import NONCONNECTABLE_IFACE_TYPES
from .models import *

CABLE_TERMINATION_TYPES = {
Expand Down Expand Up @@ -240,7 +239,6 @@ class RegionDeleteView(generic.ObjectDeleteView):
class RegionBulkImportView(generic.BulkImportView):
queryset = Region.objects.all()
model_form = forms.RegionImportForm
table = tables.RegionTable


class RegionBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -316,7 +314,6 @@ class SiteGroupDeleteView(generic.ObjectDeleteView):
class SiteGroupBulkImportView(generic.BulkImportView):
queryset = SiteGroup.objects.all()
model_form = forms.SiteGroupImportForm
table = tables.SiteGroupTable


class SiteGroupBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -422,7 +419,6 @@ class SiteDeleteView(generic.ObjectDeleteView):
class SiteBulkImportView(generic.BulkImportView):
queryset = Site.objects.all()
model_form = forms.SiteImportForm
table = tables.SiteTable


class SiteBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -499,7 +495,6 @@ class LocationDeleteView(generic.ObjectDeleteView):
class LocationBulkImportView(generic.BulkImportView):
queryset = Location.objects.all()
model_form = forms.LocationImportForm
table = tables.LocationTable


class LocationBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -568,7 +563,6 @@ class RackRoleDeleteView(generic.ObjectDeleteView):
class RackRoleBulkImportView(generic.BulkImportView):
queryset = RackRole.objects.all()
model_form = forms.RackRoleImportForm
table = tables.RackRoleTable


class RackRoleBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -728,7 +722,6 @@ class RackDeleteView(generic.ObjectDeleteView):
class RackBulkImportView(generic.BulkImportView):
queryset = Rack.objects.all()
model_form = forms.RackImportForm
table = tables.RackTable


class RackBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -781,7 +774,6 @@ class RackReservationDeleteView(generic.ObjectDeleteView):
class RackReservationImportView(generic.BulkImportView):
queryset = RackReservation.objects.all()
model_form = forms.RackReservationImportForm
table = tables.RackReservationTable

def save_object(self, object_form, request):
"""
Expand Down Expand Up @@ -854,7 +846,6 @@ class ManufacturerDeleteView(generic.ObjectDeleteView):
class ManufacturerBulkImportView(generic.BulkImportView):
queryset = Manufacturer.objects.all()
model_form = forms.ManufacturerImportForm
table = tables.ManufacturerTable


class ManufacturerBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -1083,7 +1074,6 @@ class DeviceTypeImportView(generic.BulkImportView):
]
queryset = DeviceType.objects.all()
model_form = forms.DeviceTypeImportForm
table = tables.DeviceTypeTable
related_object_forms = {
'console-ports': forms.ConsolePortTemplateImportForm,
'console-server-ports': forms.ConsoleServerPortTemplateImportForm,
Expand Down Expand Up @@ -1275,7 +1265,6 @@ class ModuleTypeImportView(generic.BulkImportView):
]
queryset = ModuleType.objects.all()
model_form = forms.ModuleTypeImportForm
table = tables.ModuleTypeTable
related_object_forms = {
'console-ports': forms.ConsolePortTemplateImportForm,
'console-server-ports': forms.ConsoleServerPortTemplateImportForm,
Expand Down Expand Up @@ -1722,7 +1711,6 @@ class DeviceRoleDeleteView(generic.ObjectDeleteView):
class DeviceRoleBulkImportView(generic.BulkImportView):
queryset = DeviceRole.objects.all()
model_form = forms.DeviceRoleImportForm
table = tables.DeviceRoleTable


class DeviceRoleBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -1786,7 +1774,6 @@ class PlatformDeleteView(generic.ObjectDeleteView):
class PlatformBulkImportView(generic.BulkImportView):
queryset = Platform.objects.all()
model_form = forms.PlatformImportForm
table = tables.PlatformTable


class PlatformBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2047,7 +2034,6 @@ class DeviceConfigContextView(ObjectConfigContextView):
class DeviceBulkImportView(generic.BulkImportView):
queryset = Device.objects.all()
model_form = forms.DeviceImportForm
table = tables.DeviceImportTable

def save_object(self, object_form, request):
obj = object_form.save()
Expand Down Expand Up @@ -2125,7 +2111,6 @@ class ModuleDeleteView(generic.ObjectDeleteView):
class ModuleBulkImportView(generic.BulkImportView):
queryset = Module.objects.all()
model_form = forms.ModuleImportForm
table = tables.ModuleTable


class ModuleBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2178,7 +2163,6 @@ class ConsolePortDeleteView(generic.ObjectDeleteView):
class ConsolePortBulkImportView(generic.BulkImportView):
queryset = ConsolePort.objects.all()
model_form = forms.ConsolePortImportForm
table = tables.ConsolePortTable


class ConsolePortBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2243,7 +2227,6 @@ class ConsoleServerPortDeleteView(generic.ObjectDeleteView):
class ConsoleServerPortBulkImportView(generic.BulkImportView):
queryset = ConsoleServerPort.objects.all()
model_form = forms.ConsoleServerPortImportForm
table = tables.ConsoleServerPortTable


class ConsoleServerPortBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2308,7 +2291,6 @@ class PowerPortDeleteView(generic.ObjectDeleteView):
class PowerPortBulkImportView(generic.BulkImportView):
queryset = PowerPort.objects.all()
model_form = forms.PowerPortImportForm
table = tables.PowerPortTable


class PowerPortBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2373,7 +2355,6 @@ class PowerOutletDeleteView(generic.ObjectDeleteView):
class PowerOutletBulkImportView(generic.BulkImportView):
queryset = PowerOutlet.objects.all()
model_form = forms.PowerOutletImportForm
table = tables.PowerOutletTable


class PowerOutletBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2484,7 +2465,6 @@ class InterfaceDeleteView(generic.ObjectDeleteView):
class InterfaceBulkImportView(generic.BulkImportView):
queryset = Interface.objects.all()
model_form = forms.InterfaceImportForm
table = tables.InterfaceTable


class InterfaceBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2549,7 +2529,6 @@ class FrontPortDeleteView(generic.ObjectDeleteView):
class FrontPortBulkImportView(generic.BulkImportView):
queryset = FrontPort.objects.all()
model_form = forms.FrontPortImportForm
table = tables.FrontPortTable


class FrontPortBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2614,7 +2593,6 @@ class RearPortDeleteView(generic.ObjectDeleteView):
class RearPortBulkImportView(generic.BulkImportView):
queryset = RearPort.objects.all()
model_form = forms.RearPortImportForm
table = tables.RearPortTable


class RearPortBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2679,7 +2657,6 @@ class ModuleBayDeleteView(generic.ObjectDeleteView):
class ModuleBayBulkImportView(generic.BulkImportView):
queryset = ModuleBay.objects.all()
model_form = forms.ModuleBayImportForm
table = tables.ModuleBayTable


class ModuleBayBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2805,7 +2782,6 @@ def post(self, request, pk):
class DeviceBayBulkImportView(generic.BulkImportView):
queryset = DeviceBay.objects.all()
model_form = forms.DeviceBayImportForm
table = tables.DeviceBayTable


class DeviceBayBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2864,7 +2840,6 @@ class InventoryItemDeleteView(generic.ObjectDeleteView):
class InventoryItemBulkImportView(generic.BulkImportView):
queryset = InventoryItem.objects.all()
model_form = forms.InventoryItemImportForm
table = tables.InventoryItemTable


class InventoryItemBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -2921,7 +2896,6 @@ class InventoryItemRoleDeleteView(generic.ObjectDeleteView):
class InventoryItemRoleBulkImportView(generic.BulkImportView):
queryset = InventoryItemRole.objects.all()
model_form = forms.InventoryItemRoleImportForm
table = tables.InventoryItemRoleTable


class InventoryItemRoleBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -3116,7 +3090,6 @@ class CableDeleteView(generic.ObjectDeleteView):
class CableBulkImportView(generic.BulkImportView):
queryset = Cable.objects.all()
model_form = forms.CableImportForm
table = tables.CableTable


class CableBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -3399,7 +3372,6 @@ def post(self, request, pk):
class VirtualChassisBulkImportView(generic.BulkImportView):
queryset = VirtualChassis.objects.all()
model_form = forms.VirtualChassisImportForm
table = tables.VirtualChassisTable


class VirtualChassisBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -3456,7 +3428,6 @@ class PowerPanelDeleteView(generic.ObjectDeleteView):
class PowerPanelBulkImportView(generic.BulkImportView):
queryset = PowerPanel.objects.all()
model_form = forms.PowerPanelImportForm
table = tables.PowerPanelTable


class PowerPanelBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -3504,7 +3475,6 @@ class PowerFeedDeleteView(generic.ObjectDeleteView):
class PowerFeedBulkImportView(generic.BulkImportView):
queryset = PowerFeed.objects.all()
model_form = forms.PowerFeedImportForm
table = tables.PowerFeedTable


class PowerFeedBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -3566,7 +3536,6 @@ class VirtualDeviceContextDeleteView(generic.ObjectDeleteView):
class VirtualDeviceContextBulkImportView(generic.BulkImportView):
queryset = VirtualDeviceContext.objects.all()
model_form = forms.VirtualDeviceContextImportForm
table = tables.VirtualDeviceContextTable


class VirtualDeviceContextBulkEditView(generic.BulkEditView):
Expand Down
2 changes: 1 addition & 1 deletion netbox/extras/tests/test_customfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ def test_import(self):
csv_data = '\n'.join(','.join(row) for row in data)

response = self.client.post(reverse('dcim:site_import'), {'data': csv_data, 'format': 'csv'})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, 302)
self.assertEqual(Site.objects.count(), 3)

# Validate data for site 1
Expand Down
7 changes: 0 additions & 7 deletions netbox/extras/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class CustomFieldDeleteView(generic.ObjectDeleteView):
class CustomFieldBulkImportView(generic.BulkImportView):
queryset = CustomField.objects.all()
model_form = forms.CustomFieldImportForm
table = tables.CustomFieldTable


class CustomFieldBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -101,7 +100,6 @@ class CustomLinkDeleteView(generic.ObjectDeleteView):
class CustomLinkBulkImportView(generic.BulkImportView):
queryset = CustomLink.objects.all()
model_form = forms.CustomLinkImportForm
table = tables.CustomLinkTable


class CustomLinkBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -149,7 +147,6 @@ class ExportTemplateDeleteView(generic.ObjectDeleteView):
class ExportTemplateBulkImportView(generic.BulkImportView):
queryset = ExportTemplate.objects.all()
model_form = forms.ExportTemplateImportForm
table = tables.ExportTemplateTable


class ExportTemplateBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -221,7 +218,6 @@ class SavedFilterDeleteView(SavedFilterMixin, generic.ObjectDeleteView):
class SavedFilterBulkImportView(SavedFilterMixin, generic.BulkImportView):
queryset = SavedFilter.objects.all()
model_form = forms.SavedFilterImportForm
table = tables.SavedFilterTable


class SavedFilterBulkEditView(SavedFilterMixin, generic.BulkEditView):
Expand Down Expand Up @@ -267,7 +263,6 @@ class WebhookDeleteView(generic.ObjectDeleteView):
class WebhookBulkImportView(generic.BulkImportView):
queryset = Webhook.objects.all()
model_form = forms.WebhookImportForm
table = tables.WebhookTable


class WebhookBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -336,7 +331,6 @@ class TagDeleteView(generic.ObjectDeleteView):
class TagBulkImportView(generic.BulkImportView):
queryset = Tag.objects.all()
model_form = forms.TagImportForm
table = tables.TagTable


class TagBulkEditView(generic.BulkEditView):
Expand Down Expand Up @@ -489,7 +483,6 @@ class ConfigTemplateDeleteView(generic.ObjectDeleteView):
class ConfigTemplateBulkImportView(generic.BulkImportView):
queryset = ConfigTemplate.objects.all()
model_form = forms.ConfigTemplateImportForm
table = tables.ConfigTemplateTable


class ConfigTemplateBulkEditView(generic.BulkEditView):
Expand Down
Loading

0 comments on commit 206d578

Please sign in to comment.