Skip to content

Commit

Permalink
libcoveweb2: additional_fields: additional_checks: jsonschema_validat…
Browse files Browse the repository at this point in the history
…ion: Print JSON values nicer

* quote strings

#20
#13
  • Loading branch information
odscjames committed Jan 3, 2023
1 parent 6b66353 commit 1b37e22
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
48 changes: 24 additions & 24 deletions cove_ofds/templates/cove_ofds/additional_checks_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.missing_node_id }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.missing_node_id %}
</td>
</tr>
{% endfor %}
Expand All @@ -50,7 +50,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.missing_node_id }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.missing_node_id %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -90,7 +90,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.incorrect_type }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.incorrect_type %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -130,7 +130,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.incorrect_coordinates }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.incorrect_coordinates %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -170,7 +170,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.incorrect_type }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.incorrect_type %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -210,7 +210,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.incorrect_coordinates }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.incorrect_coordinates %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -251,7 +251,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.phase_id_not_found }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.phase_id_not_found %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -281,7 +281,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.phase_id_not_found }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.phase_id_not_found %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -311,7 +311,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.phase_id_not_found }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.phase_id_not_found %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -356,10 +356,10 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.name_in_reference }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_in_reference %}
</td>
<td>
{{ additional_check.name_should_be }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_should_be %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -390,10 +390,10 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.name_in_reference }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_in_reference %}
</td>
<td>
{{ additional_check.name_should_be }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_should_be %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -424,10 +424,10 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.name_in_reference }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_in_reference %}
</td>
<td>
{{ additional_check.name_should_be }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_should_be %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -469,7 +469,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.organisation_id_not_found }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.organisation_id_not_found %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -499,7 +499,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.organisation_id_not_found }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.organisation_id_not_found %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -529,7 +529,7 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.organisation_id_not_found }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.organisation_id_not_found %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -577,10 +577,10 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.name_in_reference }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_in_reference %}
</td>
<td>
{{ additional_check.name_should_be }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_should_be %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -615,10 +615,10 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.name_in_reference }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_in_reference %}
</td>
<td>
{{ additional_check.name_should_be }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_should_be %}
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -649,10 +649,10 @@ <h4>
{{ additional_check.path }}
</td>
<td>
{{ additional_check.name_in_reference }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_in_reference %}
</td>
<td>
{{ additional_check.name_should_be }}
{% include "libcoveweb2/show_json_value.html" with value=additional_check.name_should_be %}
</td>
</tr>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% load i18n %}
{% load cove_tags %}
{% load ofds_cove_tags %}

<div class="collapse" id="validation_error_details_{{ error_table_id }}">
<table class="table table-condensed">
Expand Down Expand Up @@ -39,12 +38,12 @@
</td>
{% if col_instance %}
<td>
{{ error.instance|error_instance_display }}
{% include "libcoveweb2/show_json_value.html" with value=error.instance %}
</td>
{% endif %}
{% if col_validator_value %}
<td>
{{ error.validator_value }}
{% include "libcoveweb2/show_json_value.html" with value=error.validator_value %}
</td>
{% endif %}
</tr>
Expand Down
Empty file removed cove_ofds/templatetags/__init__.py
Empty file.
11 changes: 0 additions & 11 deletions cove_ofds/templatetags/ofds_cove_tags.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<td>{{info.count}}</td>
<td>
{% for example in info.examples %}
{{example}} <br />
{% include "libcoveweb2/show_json_value.html" with value=example %} <br />
{% endfor %}
</td>
<td>
Expand Down Expand Up @@ -64,7 +64,7 @@ <h4>{% blocktrans %}Child fields of {{parent_full_path}}{% endblocktrans %} </h4
<td>{{info.count}}</td>
<td>
{% for example in info.examples %}
{{example}} <br />
{% include "libcoveweb2/show_json_value.html" with value=example %} <br />
{% endfor %}
</td>
</tr>
Expand Down
7 changes: 7 additions & 0 deletions libcoveweb2/templates/libcoveweb2/show_json_value.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% load cove_tags %}

{% if value|get_variable_type == 'str' %}
"{{ value }}"
{% else %}
{{ value }}
{% endif %}
5 changes: 5 additions & 0 deletions libcoveweb2/templatetags/cove_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ def take_or_sample(population, k):
@register.filter(name="list_from_attribute")
def list_from_attribute(list_of_dicts, key_name):
return [value[key_name] for value in list_of_dicts]


@register.filter(name="get_variable_type")
def get_variable_type(value):
return type(value).__name__

0 comments on commit 1b37e22

Please sign in to comment.