Skip to content

Instantly share code, notes, and snippets.

@salsa-nathan
Last active September 23, 2019 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsa-nathan/e52902b82102f484e56b06c651d2321d to your computer and use it in GitHub Desktop.
Save salsa-nathan/e52902b82102f484e56b06c651d2321d to your computer and use it in GitHub Desktop.
CKAN - Hide `ckanext-validation` metadata fields on resource additional info if validation schema not added to resource.

The resource_read.html snippet assumes:

  1. You have the ckanext-validation extension installed and configured.
  2. You have the ckanext-scheming extension installed and configured.
  3. You have a CKAN extension that implements the IConfigurer interface to add template overrides.
  4. You save the snippet as templates/scheming/package/resource_read.html in your CKAN extension.
  5. Your CKAN extension appears before the scheming_datasets and validation extension in ckan.plugins setting of your CKAN .ini file.

An example implementation can be found here: https://github.com/salsadigitalauorg/ckanext-hide-schema-metadata

{% ckan_extends %}
{%- block resource_fields -%}
{%- if 'schema' not in res -%}
{%- do exclude_fields.append('schema') -%}
{%- do exclude_fields.append('validation_options') -%}
{%- do exclude_fields.append('validation_status') -%}
{%- do exclude_fields.append('validation_timestamp') -%}
{%- endif -%}
{%- if 'validation_options' not in res and 'validation_options' not in exclude_fields -%}
{%- do exclude_fields.append('validation_options') -%}
{%- endif -%}
{{ super() }}
{%- endblock -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment