Skip to content

Commit 97bcdc6

Browse files
committed
fix(templates): syntax;
- `h` -> `helpers` - Humanization fixes.
1 parent dc4633c commit 97bcdc6

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

ckan/templates/macros/form/resource_validation_errors.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,25 @@
1717

1818

1919
{# (canada fork only): error -> danger BS version #}
20-
{% macro resource_validation_errors(errors={}, type="danger", classes=[], pkg_name='', helpers={}) %}
20+
{% macro resource_validation_errors(errors={}, type="danger", classes=[], pkg_name='', dataset_type='dataset', helpers={}) %}
2121
{% if errors %}
2222
<div class="error-explanation alert alert-{{ type }}{{ " " ~ classes | join(' ') }}">
23-
<h3>{{ h.humanize_entity_type('package', dataset_type, 'other errors') or _('Errors in dataset') }}</h3>
23+
<h3>{{ helpers.humanize_entity_type('package', dataset_type, 'other errors') or _('Errors in dataset') }}</h3>
2424
{% if 'dataset' in errors and errors.dataset %}
2525
{% set dataset_link = helpers.url_for('dataset.read', id=pkg_name) %}
26-
<p>{{ h.humanize_entity_type('package', dataset_type, 'other errors package').format(dataset_link) or _('The <a href="{}" target="_blank">dataset</a> contains errors:').format(dataset_link) }}</p>
26+
{% set humanized_label = helpers.humanize_entity_type('package', dataset_type, 'other errors package') %}
27+
{% if humanized_label %}
28+
{% set humanized_label = humanized_label.format(dataset_link)|safe %}
29+
{% endif %}
30+
<p>{{ humanized_label or _('The <a href="{}" target="_blank">dataset</a> contains errors:').format(dataset_link) }}</p>
2731
<ul>
2832
{% for field_id, field_errs in errors.dataset.items() %}
2933
<li data-field-label="{{ field_id }}">{% if field_id %}{{ field_id }}{{_(':')}} {% endif %}{{ field_errs|join(', ') }}</li>
3034
{% endfor %}
3135
</ul>
3236
{% endif %}
3337
{% if 'resources' in errors and errors.resources %}
34-
<p>{{ h.humanize_entity_type('package', dataset_type, 'other errors resources') or _('The dataset contains invalid resources:') }}</p>
38+
<p>{{ helpers.humanize_entity_type('package', dataset_type, 'other errors resources') or _('The dataset contains invalid resources:') }}</p>
3539
<ul>
3640
{% for res_id, errs in errors.resources.items() %}
3741
<li><a href="{{ helpers.url_for('resource.read', id=pkg_name, resource_id=res_id) }}" target="_blank">{{ res_id }}</a></li>

ckan/templates/package/confirm_delete_resource.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{# TODO: upstream contrib?? #}
1919
{% block errors %}
2020
{% if resource_validation_errors %}
21-
{{ form.resource_validation_errors(errors=resource_validation_errors, pkg_name=pkg_id, helpers=h) }}
21+
{{ form.resource_validation_errors(errors=resource_validation_errors, pkg_name=pkg_id, dataset_type=dataset_type, helpers=h) }}
2222
{% else %}
2323
{{ form.errors(errors=errors) }}
2424
{% endif %}

ckan/templates/package/snippets/resource_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{# TODO: upstream contrib?? #}
1919
{% block errors %}
2020
{% if resource_validation_errors %}
21-
{{ form.resource_validation_errors(errors=resource_validation_errors, pkg_name=pkg_name, helpers=h) }}
21+
{{ form.resource_validation_errors(errors=resource_validation_errors, pkg_name=pkg_name, dataset_type=dataset_type, helpers=h) }}
2222
{% else %}
2323
{{ form.errors(errors=errors) }}
2424
{% endif %}

0 commit comments

Comments
 (0)