From 596658beda8fb12b9eda2cb087099ab4def7c700 Mon Sep 17 00:00:00 2001 From: Eg0ra Date: Wed, 27 Nov 2024 14:28:57 +0700 Subject: [PATCH] Remove extra loop in result page if errors --- HISTORY.rst | 1 + .../celery_import_results.html | 96 +++++++++---------- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index be95f7f..a63cdc8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,6 +9,7 @@ UNRELEASED * Add displaying resources for import form * Fix autofill `Format` by file extension * Add `Totals` section + * Remove extra loop if errors in input file (https://github.com/saritasa-nest/django-import-export-extensions/issues/74) * Fixed display of progress bar when task is waiting to run (https://github.com/saritasa-nest/django-import-export-extensions/issues/68) * Improve progress bar style (https://github.com/saritasa-nest/django-import-export-extensions/issues/72) diff --git a/import_export_extensions/templates/admin/import_export_extensions/celery_import_results.html b/import_export_extensions/templates/admin/import_export_extensions/celery_import_results.html index 0314f5a..7b28486 100644 --- a/import_export_extensions/templates/admin/import_export_extensions/celery_import_results.html +++ b/import_export_extensions/templates/admin/import_export_extensions/celery_import_results.html @@ -107,59 +107,57 @@

{% trans "Errors" %}

{% endfor %} {% endfor %} - {% for invalid_row in result.invalid_rows %} -

{% trans "Some rows failed to validate" %}

+

{% trans "Some rows failed to validate" %}

-

{% trans "Please correct these errors in your data where possible, then reupload it using the form above." %}

- - +

{% trans "Please correct these errors in your data where possible, then reupload it using the form above." %}

+
+ + + + + {% for field in result.diff_headers %} + + {% endfor %} + + + + {% for row in result.invalid_rows %} - - - {% for field in result.diff_headers %} - + + + {% for field in row.values %} + {% endfor %} - - - {% for row in result.invalid_rows %} - - - - {% for field in row.values %} - - {% endfor %} - - {% endfor %} - -
{% trans "Row" %}{% trans "Errors" %}{{ field }}
{% trans "Row" %}{% trans "Errors" %}{{ field }}{{ row.number }} + {{ row.error_count }} +
+
    + {% for field_name, error_list in row.field_specific_errors.items %} +
  • + {{ field_name }} +
      + {% for error in error_list %} +
    • {{ error }}
    • + {% endfor %} +
    +
  • + {% endfor %} + {% if row.non_field_specific_errors %} +
  • + {% trans "Non field specific" %} +
      + {% for error in row.non_field_specific_errors %} +
    • {{ error }}
    • + {% endfor %} +
    +
  • + {% endif %} +
+
+
{{ field }}
{{ row.number }} - {{ row.error_count }} -
-
    - {% for field_name, error_list in row.field_specific_errors.items %} -
  • - {{ field_name }} -
      - {% for error in error_list %} -
    • {{ error }}
    • - {% endfor %} -
    -
  • - {% endfor %} - {% if row.non_field_specific_errors %} -
  • - {% trans "Non field specific" %} -
      - {% for error in row.non_field_specific_errors %} -
    • {{ error }}
    • - {% endfor %} -
    -
  • - {% endif %} -
-
-
{{ field }}
- {% endfor %} + {% endfor %} + + {% endif %} {% if import_job.import_status in import_job.success_statuses %}