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

Admin UI 1675 #1691

Merged
merged 13 commits into from
Nov 25, 2023
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,5 @@ The following is a list of much appreciated contributors:
* EricOuma (Eric Ouma)
* Glay00 (Gleb Gorelov)
* PrashansaChaudhary (Prashansa Chaudhary)
* Vedang Barhate (bvedang)
* Vedang Barhate (bvedang)
* RobTilton (Robert Tilton)
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Please refer to :doc:`release notes<release_notes>`.
- fix declaring existing model field(s) in ModelResource altering export order (#1663)
- Updated `docker-compose` command with latest version syntax in `runtests.sh` (#1686)
- Support export from model change form (#1687)
- Updated Admin UI to track deleted and skipped Imports (#1691)

4.0.0-beta.1 (2023-11-16)
--------------------------
Expand Down
10 changes: 10 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,13 @@ Development
Run this command from the base project directory::

git config blame.ignoreRevsFile .git-blame-ignore-revs

Once you have cloned and checked out the repository, you can install a new development environment as follows::

python -m venv django-import-export-venv
source django-import-export-venv/bin/activate
pip install -r requirements/base.txt -r requirements/test.txt

You can run the test suite with::

make clean test
6 changes: 6 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ selected items using an export admin action. However this meant that the export
possible to select the export resource. This has been fixed in v4 so that export workflow is now present when
exporting via the Admin UI action. For more information see :ref:`export documentation<export_via_admin_action>`.

Success message
---------------

The success message shown on successful import has been updated to include the number of 'deleted' and 'skipped' rows.
See `this PR <https://github.com/django-import-export/django-import-export/issues/1691>`_.

API changes
===========

Expand Down
4 changes: 3 additions & 1 deletion import_export/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,12 @@ def add_success_message(self, result, request):
opts = self.model._meta

success_message = _(
"Import finished, with {} new and " "{} updated {}."
"Import finished: {} new, {} updated, {} deleted and {} skipped {}."
).format(
result.totals[RowResult.IMPORT_TYPE_NEW],
result.totals[RowResult.IMPORT_TYPE_UPDATE],
result.totals[RowResult.IMPORT_TYPE_DELETE],
result.totals[RowResult.IMPORT_TYPE_SKIP],
opts.verbose_name_plural,
)

Expand Down
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ memory-profiler==0.61.0
django-extensions==3.2.3
coverage==7.3.2
tablib[all]==3.5.0
setuptools-scm==8.0.4
39 changes: 22 additions & 17 deletions tests/core/tests/admin_integration/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def test_import(self):
self.assertEqual(response.status_code, 200)
self.assertContains(
response,
_("Import finished, with {} new and {} updated {}.").format(
1, 0, Book._meta.verbose_name_plural
),
_(
"Import finished: {} new, {} updated, {} deleted and {} skipped {}."
).format(1, 0, 0, 0, Book._meta.verbose_name_plural),
)

@override_settings(DEBUG=True)
Expand Down Expand Up @@ -135,9 +135,9 @@ def test_import_second_resource(self):
self.assertEqual(response.status_code, 200)
self.assertContains(
response,
_("Import finished, with {} new and {} updated {}.").format(
0, 1, Book._meta.verbose_name_plural
),
_(
"Import finished: {} new, {} updated, {} deleted and {} skipped {}."
).format(0, 1, 0, 0, Book._meta.verbose_name_plural),
)
# Check, that we really use second resource - author_email didn't get imported
self.assertEqual(Book.objects.get(id=1).author_email, "")
Expand Down Expand Up @@ -266,9 +266,9 @@ def test_import_mac(self):
self.assertEqual(response.status_code, 200)
self.assertContains(
response,
_("Import finished, with {} new and {} updated {}.").format(
1, 0, Book._meta.verbose_name_plural
),
_(
"Import finished: {} new, {} updated, {} deleted and {} skipped {}."
).format(1, 0, 0, 0, Book._meta.verbose_name_plural),
)

def test_import_export_buttons_visible_without_add_permission(self):
Expand Down Expand Up @@ -387,9 +387,9 @@ def test_import_with_customized_forms(self):
self.assertEqual(response.status_code, 200)
self.assertContains(
response,
_("Import finished, with {} new and {} updated {}.").format(
1, 0, EBook._meta.verbose_name_plural
),
_(
"Import finished: {} new, {} updated, {} deleted and {} skipped {}."
).format(1, 0, 0, 0, EBook._meta.verbose_name_plural),
)

def test_get_skip_admin_log_attribute(self):
Expand Down Expand Up @@ -580,7 +580,8 @@ def _is_str_in_response(self, filename, input_format, encoding=None):

self.assertEqual(response.status_code, 200)
self.assertContains(
response, "Import finished, with 1 new and 0 updated books."
response,
"Import finished: 1 new, 0 updated, 0 deleted and 0 skipped books.",
)

@override_settings(
Expand Down Expand Up @@ -718,7 +719,8 @@ def test_import_action_create(self):
"books.csv",
"0",
follow=True,
str_in_response="Import finished, with 1 new and 0 updated books.",
str_in_response="Import finished: 1 new, 0 updated, "
+ "0 deleted and 0 skipped books.",
)
self.assertEqual(1, Book.objects.count())

Expand Down Expand Up @@ -792,7 +794,8 @@ def test_import_action_mac(self):
"books-mac.csv",
"0",
follow=True,
str_in_response="Import finished, with 1 new and 0 updated books.",
str_in_response="Import finished: 1 new, 0 updated, "
+ "0 deleted and 0 skipped books.",
)

@ignore_widget_deprecation_warning
Expand All @@ -802,7 +805,8 @@ def test_import_action_iso_8859_1(self):
"0",
"ISO-8859-1",
follow=True,
str_in_response="Import finished, with 1 new and 0 updated books.",
str_in_response="Import finished: 1 new, 0 updated, "
+ "0 deleted and 0 skipped books.",
)

def test_import_action_decode_error(self):
Expand All @@ -823,5 +827,6 @@ def test_import_action_binary(self):
"books.xls",
"1",
follow=True,
str_in_response="Import finished, with 1 new and 0 updated books.",
str_in_response="Import finished: 1 new, 0 updated, "
+ "0 deleted and 0 skipped books.",
)