Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deps] Update django-import-export requirement from ~=3.3.0 to ~=4.1.1 #915

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions openwisp_controller/config/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from django.utils.translation import gettext_lazy as _
from flat_json_widget.widgets import FlatJsonWidget
from import_export.admin import ImportExportMixin
from import_export.forms import ExportForm
from openwisp_ipam.filters import SubnetFilter
from swapper import load_model

Expand Down Expand Up @@ -744,6 +745,7 @@ def add_reversion_following(cls, follow):


class DeviceAdminExportable(ImportExportMixin, DeviceAdmin):
export_form_class = ExportForm
resource_class = DeviceResource
# needed to support both reversion and import-export
change_list_template = 'admin/config/change_list_device.html'
Expand Down
8 changes: 4 additions & 4 deletions openwisp_controller/config/exportable.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def validate_instance(
if config.device_id != instance.id:
config.device_id = instance.id

def after_save_instance(self, instance, using_transactions, dry_run):
super().after_save_instance(instance, using_transactions, dry_run)
if not dry_run:
# save config afte device has been imported
def after_save_instance(self, instance, row, **kwargs):
super().after_save_instance(instance, row, **kwargs)
if not self._is_dry_run(kwargs):
# save config after device has been imported
if instance._has_config():
instance.config.save()

Expand Down
14 changes: 7 additions & 7 deletions openwisp_controller/config/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_device_import_export_buttons(self):

def test_device_export(self):
response = self.client.post(
reverse(f'admin:{self.app_label}_device_export'), {'file_format': '0'}
reverse(f'admin:{self.app_label}_device_export'), {'format': '0'}
)
self.assertNotContains(response, 'error')
self.assertIsNotNone(response.get('Content-Disposition'))
Expand All @@ -101,7 +101,7 @@ def test_device_import(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv},
{'format': '0', 'import_file': csv},
)
self.assertNotContains(response, 'errorlist')
self.assertNotContains(response, 'Errors')
Expand All @@ -125,7 +125,7 @@ def test_device_import_empty_config(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv, 'file_name': 'test.csv'},
{'format': '0', 'import_file': csv, 'file_name': 'test.csv'},
)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_device_import_missing_config(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv, 'file_name': 'test.csv'},
{'format': '0', 'import_file': csv, 'file_name': 'test.csv'},
)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_device_import_config_not_templates(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv, 'file_name': 'test.csv'},
{'format': '0', 'import_file': csv, 'file_name': 'test.csv'},
)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
Expand Down Expand Up @@ -629,7 +629,7 @@ def test_device_import_with_group_apply_templates(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv, 'file_name': 'test.csv'},
{'format': '0', 'import_file': csv, 'file_name': 'test.csv'},
)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
Expand Down Expand Up @@ -675,7 +675,7 @@ def test_device_import_templates_and_config(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv, 'file_name': 'test.csv'},
{'format': '0', 'import_file': csv, 'file_name': 'test.csv'},
)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
Expand Down
10 changes: 5 additions & 5 deletions openwisp_controller/geo/exportable.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def dehydrate_coords(self, device):
except (ObjectDoesNotExist, AttributeError):
pass

def after_import_instance(self, instance, new, row_number=None, **kwargs):
super().after_import_instance(instance, new, row_number, **kwargs)
def after_init_instance(self, instance, new, row, **kwargs):
super().after_init_instance(instance, new, row, **kwargs)
if not hasattr(instance, 'devicelocation'):
instance.devicelocation = DeviceLocation()

Expand All @@ -68,9 +68,9 @@ def validate_instance(
if device_location.location_id or device_location.floorplan_id:
device_location.content_object_id = instance.id

def after_save_instance(self, instance, using_transactions, dry_run):
super().after_save_instance(instance, using_transactions, dry_run)
if not dry_run:
def after_save_instance(self, instance, row, **kwargs):
super().after_save_instance(instance, row, **kwargs)
if not self._is_dry_run(kwargs):
device_location = instance.devicelocation
if device_location.location_id or device_location.floorplan_id:
device_location.save()
Expand Down
4 changes: 2 additions & 2 deletions openwisp_controller/geo/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def test_device_import_geo(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv, 'file_name': 'test.csv'},
{'format': '0', 'import_file': csv, 'file_name': 'test.csv'},
)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_device_import_geo_no_floorplan(self):
csv = ContentFile(contents)
response = self.client.post(
reverse(f'admin:{self.app_label}_device_import'),
{'input_format': '0', 'import_file': csv, 'file_name': 'test.csv'},
{'format': '0', 'import_file': csv, 'file_name': 'test.csv'},
)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ scp~=0.15.0
django-cache-memoize~=0.2.0
shortuuid~=1.0.13
netaddr~=1.3.0
django-import-export~=3.3.0
django-import-export~=4.1.1
Loading