Skip to content

Commit

Permalink
remove unreachable except block from admin.py (#1825)
Browse files Browse the repository at this point in the history
* remove unreachable code

* updated changelog

* updated changelog

* updated changelog
  • Loading branch information
matthewhegarty committed May 13, 2024
1 parent 01f4aca commit c69e32d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
3 changes: 2 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Changelog
4.0.2 (unreleased)
------------------

- fix allow ``column_name`` to be declared in ``fields`` list (`1815 <https://github.com/django-import-export/django-import-export/pull/1815>`_)
- fix export with custom column name (`1821 <https://github.com/django-import-export/django-import-export/pull/1821>`_)
- fix allow ``column_name`` to be declared in ``fields`` list (`1822 <https://github.com/django-import-export/django-import-export/pull/1822>`_)
- fix clash between ``key_is_id`` and ``use_natural_foreign_keys`` (`1824 <https://github.com/django-import-export/django-import-export/pull/1824>`_)
- remove unreachable code (`1825 <https://github.com/django-import-export/django-import-export/pull/1825>`_)

4.0.1 (2024-05-08)
------------------
Expand Down
35 changes: 13 additions & 22 deletions import_export/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from django.utils.translation import gettext_lazy as _
from django.views.decorators.http import require_POST

from import_export import exceptions

from .forms import ConfirmImportForm, ImportForm, SelectableFieldsExportForm
from .mixins import BaseExportMixin, BaseImportMixin
from .results import RowResult
Expand Down Expand Up @@ -507,27 +505,20 @@ def import_action(self, request, **kwargs):
imp_kwargs = self.get_import_data_kwargs(
request=request, form=import_form, **kwargs
)
try:
result = resource.import_data(
dataset,
dry_run=True,
raise_errors=False,
file_name=import_file.name,
user=request.user,
**imp_kwargs,
)
context["result"] = result

if (
not result.has_errors()
and not result.has_validation_errors()
):
context["confirm_form"] = self.create_confirm_form(
request, import_form=import_form
)
except exceptions.FieldError as e:
messages.error(request, str(e))
result = resource.import_data(
dataset,
dry_run=True,
raise_errors=False,
file_name=import_file.name,
user=request.user,
**imp_kwargs,
)
context["result"] = result

if not result.has_errors() and not result.has_validation_errors():
context["confirm_form"] = self.create_confirm_form(
request, import_form=import_form
)
else:
res_kwargs = self.get_import_resource_kwargs(
request=request, form=import_form, **kwargs
Expand Down

0 comments on commit c69e32d

Please sign in to comment.