diff --git a/cove_ofds/templates/cove_ofds/additional_checks_table.html b/cove_ofds/templates/cove_ofds/additional_checks_table.html index bdcd31f..5ae1db7 100644 --- a/cove_ofds/templates/cove_ofds/additional_checks_table.html +++ b/cove_ofds/templates/cove_ofds/additional_checks_table.html @@ -34,7 +34,7 @@
- {{ error.instance|error_instance_display }} + {% include "libcoveweb2/show_json_value.html" with value=error.instance %} | {% endif %} {% if col_validator_value %}- {{ error.validator_value }} + {% include "libcoveweb2/show_json_value.html" with value=error.validator_value %} | {% endif %} diff --git a/cove_ofds/templatetags/__init__.py b/cove_ofds/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/cove_ofds/templatetags/ofds_cove_tags.py b/cove_ofds/templatetags/ofds_cove_tags.py deleted file mode 100644 index 178dfa4..0000000 --- a/cove_ofds/templatetags/ofds_cove_tags.py +++ /dev/null @@ -1,11 +0,0 @@ -from django import template - -register = template.Library() - - -@register.filter(name="error_instance_display") -def error_instance_display(input): - if isinstance(input, str): - return '"' + input + '"' - else: - return str(input) diff --git a/libcoveweb2/templates/libcoveweb2/additional_fields_table.html b/libcoveweb2/templates/libcoveweb2/additional_fields_table.html index 98b3e7f..0f80b5d 100644 --- a/libcoveweb2/templates/libcoveweb2/additional_fields_table.html +++ b/libcoveweb2/templates/libcoveweb2/additional_fields_table.html @@ -20,7 +20,7 @@{{info.count}} |
{% for example in info.examples %}
- {{example}} + {% include "libcoveweb2/show_json_value.html" with value=example %} {% endfor %} |
@@ -64,7 +64,7 @@ {% blocktrans %}Child fields of {{parent_full_path}}{% endblocktrans %}{{info.count}} |
{% for example in info.examples %}
- {{example}} + {% include "libcoveweb2/show_json_value.html" with value=example %} {% endfor %} |
diff --git a/libcoveweb2/templates/libcoveweb2/show_json_value.html b/libcoveweb2/templates/libcoveweb2/show_json_value.html
new file mode 100644
index 0000000..98cba3d
--- /dev/null
+++ b/libcoveweb2/templates/libcoveweb2/show_json_value.html
@@ -0,0 +1,7 @@
+{% load cove_tags %}
+
+{% if value|get_variable_type == 'str' %}
+ "{{ value }}"
+{% else %}
+ {{ value }}
+{% endif %}
diff --git a/libcoveweb2/templatetags/cove_tags.py b/libcoveweb2/templatetags/cove_tags.py
index 05cb9f9..0cbff92 100644
--- a/libcoveweb2/templatetags/cove_tags.py
+++ b/libcoveweb2/templatetags/cove_tags.py
@@ -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__