-
- {% trans 'Structural Errors' %}
-
+{% with validation_errors=validation_errors_grouped.required error_prefix='required-' %}
+ {% if validation_errors %}
+ {% for error_json, values in validation_errors %}
+ {% with error=error_json|json_decode %}
+ {% cove_modal_errors className="validation-errors-"|concat:error_prefix|concat:forloop.counter modalTitle=error.message errorList=values file_type=file_type full_table=True %}
+ {% endwith %}
+ {% endfor %}
+
+
+
+
+
+ {% trans 'Structural Errors - Required Fields' %}
+
+
+
+ {% blocktrans %}Some or all of your data is missing fields which are required by the OCDS schema.{% endblocktrans %}
+ {% include "cove_ocds/validation_table.html" %}
+
-
- {% include "validation_table.html" %}
+
+ {% endif %}
+{% endwith %}
+
+{% with validation_errors=validation_errors_grouped.format error_prefix='format-' %}
+ {% if validation_errors %}
+ {% for error_json, values in validation_errors %}
+ {% with error=error_json|json_decode %}
+ {% cove_modal_errors className="validation-errors-"|concat:error_prefix|concat:forloop.counter modalTitle=error.message errorList=values file_type=file_type full_table=True %}
+ {% endwith %}
+ {% endfor %}
+
+
+
+
+
+ {% trans 'Structural Errors - Format' %}
+
+
+
+ {% blocktrans %}Some or all of your data includes fields which are incorrectly formatted.{% endblocktrans %}
+ {% include "cove_ocds/validation_table.html" %}
+
-
-{% endif %}
+
+ {% endif %}
+{% endwith %}
+
+{% with validation_errors=validation_errors_grouped.other error_prefix='other-' %}
+ {% if validation_errors %}
+ {% for error_json, values in validation_errors %}
+ {% with error=error_json|json_decode %}
+ {% cove_modal_errors className="validation-errors-"|concat:error_prefix|concat:forloop.counter modalTitle=error.message errorList=values file_type=file_type full_table=True %}
+ {% endwith %}
+ {% endfor %}
+
+
+
+
+
+ {% trans 'Structural Errors - Other' %}
+
+
+
+ {% blocktrans %}Some or all of your data has validation errors.{% endblocktrans %}
+ {% include "cove_ocds/validation_table.html" %}
+
+
+
+ {% endif %}
+{% endwith %}
+
+
{% if structure_warnings %}
diff --git a/cove_ocds/templates/cove_ocds/validation_table.html b/cove_ocds/templates/cove_ocds/validation_table.html
new file mode 100644
index 000000000..2127110df
--- /dev/null
+++ b/cove_ocds/templates/cove_ocds/validation_table.html
@@ -0,0 +1,87 @@
+{% load i18n %}
+{% load cove_tags %}
+
+
+
+
+ {% trans 'Error Description' %} |
+ {% trans 'Error Count' %} |
+ {% trans 'First 3 Examples' %} |
+ {% trans 'Location of first 3 errors' %} |
+ {% if file_type == 'xlsx' or file_type == 'csv' %}
+ {% trans 'Spreadsheet Location of first 3 errors' %} |
+ {% endif %}
+
+
+
+{% for error_json, values in validation_errors %}
+{% with error=error_json|json_decode %}
+
+ {% if error.message_safe %}
+
+
+ {{ error.message_safe | safe }}
+ {% if error.message_type in common_error_types %}
+ (more info)
+ {% endif %}
+
+ {% if 'schema_title' in error %}
+
+ {{ error.schema_title }}
+ {{ error.schema_description_safe | safe }}
+
+ {% endif %}
+ |
+ {% elif error.message_type in common_error_types %}
+ {{error.message}} |
+ {% else %}
+ {{error.message}} |
+ {% endif %}
+
+ {% if values|length > 3 %}
+ {% if error_prefix %}
+
+ {% else %}
+
+ {% endif %}
+ {{values|length}}
+
+ {% else %}
+ {{values|length}}
+ {% endif %}
+ |
+
+
+ {% for value in values|slice:":3" %}
+ - {{value.value}}
+ {% endfor %}
+
+ |
+
+
+ {% for value in values|slice:":3" %}
+ -
+ {% if value.line %}
+ {% trans 'Path:' %} {{value.path}}
+ {% trans 'Line:' %} {{value.line}}
+ {% else %}
+ {{ value.path }}
+ {% endif %}
+
+ {% endfor %}
+
+ |
+ {% if file_type == 'xlsx' or file_type == 'csv' %}
+
+
+ {% for value in values|slice:":3" %}
+ - Sheet: {{value.sheet}} Row: {{value.row_number}} {% if value.header %} Column: {{value.header}} {% endif %}
+ {% endfor %}
+
+ |
+ {% endif %}
+
+{% endwith %}
+{% endfor %}
+
+
diff --git a/cove_ocds/views.py b/cove_ocds/views.py
index 710bac490..720d12fdf 100644
--- a/cove_ocds/views.py
+++ b/cove_ocds/views.py
@@ -22,6 +22,7 @@
from libcove.lib.exceptions import CoveInputDataError
from . lib.ocds_show_extra import add_extra_fields
from cove.views import explore_data_context
+from cove_ocds.lib.views import group_validation_errors
logger = logging.getLogger(__name__)
@@ -164,7 +165,8 @@ def explore_ocds(request, pk):
context.update({
'data_schema_version': db_data.data_schema_version,
- 'first_render': not db_data.rendered
+ 'first_render': not db_data.rendered,
+ 'validation_errors_grouped': group_validation_errors(context['validation_errors']),
})
schema_version = getattr(schema_ocds, 'version', None)