Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions netbox/dcim/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ class RackReservationImportView(generic.BulkImportView):
model_form = forms.RackReservationCSVForm
table = tables.RackReservationTable

def _save_obj(self, obj_form, request):
def save_object(self, obj_form, request):
"""
Assign the currently authenticated user to the RackReservation.
"""
Expand Down Expand Up @@ -1082,7 +1082,7 @@ class DeviceTypeInventoryItemsView(DeviceTypeComponentsView):
)


class DeviceTypeImportView(generic.ObjectImportView):
class DeviceTypeImportView(generic.BulkImportView):
additional_permissions = [
'dcim.add_devicetype',
'dcim.add_consoleporttemplate',
Expand All @@ -1098,6 +1098,7 @@ class DeviceTypeImportView(generic.ObjectImportView):
]
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 @@ -1267,7 +1268,7 @@ class ModuleTypeRearPortsView(ModuleTypeComponentsView):
)


class ModuleTypeImportView(generic.ObjectImportView):
class ModuleTypeImportView(generic.BulkImportView):
additional_permissions = [
'dcim.add_moduletype',
'dcim.add_consoleporttemplate',
Expand All @@ -1280,6 +1281,7 @@ class ModuleTypeImportView(generic.ObjectImportView):
]
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 @@ -2026,8 +2028,7 @@ class ChildDeviceBulkImportView(generic.BulkImportView):
table = tables.DeviceImportTable
template_name = 'dcim/device_import_child.html'

def _save_obj(self, obj_form, request):

def save_object(self, obj_form, request):
obj = obj_form.save()

# Save the reverse relation to the parent device bay
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 @@ -935,7 +935,7 @@ def test_import(self):
)
csv_data = '\n'.join(','.join(row) for row in data)

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

Expand Down
22 changes: 13 additions & 9 deletions netbox/ipam/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,11 @@ class L2VPNTerminationTestCase(
def setUpTestData(cls):
device = create_test_device('Device 1')
interface = Interface.objects.create(name='Interface 1', device=device, type='1000baset')
l2vpn = L2VPN.objects.create(name='L2VPN 1', slug='l2vpn-1', type=L2VPNTypeChoices.TYPE_VXLAN, identifier=650001)
l2vpns = (
L2VPN(name='L2VPN 1', slug='l2vpn-1', type=L2VPNTypeChoices.TYPE_VXLAN, identifier=650001),
L2VPN(name='L2VPN 2', slug='l2vpn-2', type=L2VPNTypeChoices.TYPE_VXLAN, identifier=650002),
)
L2VPN.objects.bulk_create(l2vpns)

vlans = (
VLAN(name='Vlan 1', vid=1001),
Expand All @@ -933,14 +937,14 @@ def setUpTestData(cls):
VLAN.objects.bulk_create(vlans)

terminations = (
L2VPNTermination(l2vpn=l2vpn, assigned_object=vlans[0]),
L2VPNTermination(l2vpn=l2vpn, assigned_object=vlans[1]),
L2VPNTermination(l2vpn=l2vpn, assigned_object=vlans[2])
L2VPNTermination(l2vpn=l2vpns[0], assigned_object=vlans[0]),
L2VPNTermination(l2vpn=l2vpns[0], assigned_object=vlans[1]),
L2VPNTermination(l2vpn=l2vpns[0], assigned_object=vlans[2])
)
L2VPNTermination.objects.bulk_create(terminations)

cls.form_data = {
'l2vpn': l2vpn.pk,
'l2vpn': l2vpns[0].pk,
'device': device.pk,
'interface': interface.pk,
}
Expand All @@ -953,10 +957,10 @@ def setUpTestData(cls):
)

cls.csv_update_data = (
"id,l2vpn",
f"{terminations[0].pk},L2VPN 2",
f"{terminations[1].pk},L2VPN 2",
f"{terminations[2].pk},L2VPN 2",
f"id,l2vpn",
f"{terminations[0].pk},{l2vpns[0].name}",
f"{terminations[1].pk},{l2vpns[0].name}",
f"{terminations[2].pk},{l2vpns[0].name}",
)

cls.bulk_edit_data = {}
Expand Down
7 changes: 5 additions & 2 deletions netbox/netbox/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from dcim.models import *
from users.models import ObjectPermission
from utilities.forms.choices import ImportFormatChoices
from utilities.testing import ModelViewTestCase, create_tags


Expand All @@ -27,7 +28,8 @@ def test_valid_tags(self):
)

data = {
'csv': self._get_csv_data(csv_data),
'format': ImportFormatChoices.CSV,
'data': self._get_csv_data(csv_data),
}

# Assign model-level permission
Expand Down Expand Up @@ -67,7 +69,8 @@ def test_invalid_tags(self):
)

data = {
'csv': self._get_csv_data(csv_data),
'format': ImportFormatChoices.CSV,
'data': self._get_csv_data(csv_data),
}

# Assign model-level permission
Expand Down
Loading