Skip to content

Commit

Permalink
Merge pull request #23 from saritasa-nest/feature/extend-import-resul…
Browse files Browse the repository at this point in the history
…ts-template

Extend import results template
  • Loading branch information
yalef committed Nov 3, 2023
2 parents c8ab746 + ad6f027 commit 498d410
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 9 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ History
0.4.2 (2023-10-20)
------------------
* Add base model for `ImportJob` and `ExportJob`
* Extend import results template: show validation errors in table

0.4.1 (2023-09-25)
------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script type="text/javascript" src="{% static 'admin/js/jquery.init.js' %}"></script>
<script type="text/javascript" src="{% static 'import_export_extensions/js/admin/admin.js' %}"></script>
<link rel="stylesheet" type="text/css" href="{% static "import_export_extensions/css/admin/import_result_diff.css" %}"/>
<link rel="stylesheet" type="text/css" href="{% static "import_export/import.css"" %}"/>
{% endblock %}


Expand Down Expand Up @@ -99,16 +100,57 @@ <h2>{% trans "Errors" %}</h2>
{% endfor %}
{% endfor %}
{% for invalid_row in result.invalid_rows %}
<li>
<b>{% trans "Row number" %}: {{ invalid_row.number }}</b><br>
{% for field, errors in invalid_row.error_dict.items %}
<b>{{ field }}</b>
<br>
{% for error in errors %}
<b style="color: red">{{ error }}</b><br>
<h2>{% trans "Some rows failed to validate" %}</h2>

<p>{% trans "Please correct these errors in your data where possible, then reupload it using the form above." %}</p>
<table class="import-preview">
<thead>
<tr>
<th>{% trans "Row" %}</th>
<th>{% trans "Errors" %}</th>
{% for field in result.diff_headers %}
<th>{{ field }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in result.invalid_rows %}
<tr>
<td>{{ row.number }} </td>
<td class="errors">
<span class="validation-error-count">{{ row.error_count }}</span>
<div class="validation-error-container">
<ul class="validation-error-list">
{% for field_name, error_list in row.field_specific_errors.items %}
<li>
<span class="validation-error-field-label">{{ field_name }}</span>
<ul>
{% for error in error_list %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
{% if row.non_field_specific_errors %}
<li>
<span class="validation-error-field-label">{% trans "Non field specific" %}</span>
<ul>
{% for error in row.non_field_specific_errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</li>
{% endif %}
</ul>
</div>
</td>
{% for field in row.values %}
<td>{{ field }}</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</li>
</tbody>
</table>
{% endfor %}
</ul>
{% endif %}
Expand Down

0 comments on commit 498d410

Please sign in to comment.