From 4ae35582a02cc9f7412af23ecba541f4a8720b03 Mon Sep 17 00:00:00 2001 From: Paul DeKraker Date: Tue, 29 Nov 2022 23:21:17 -0500 Subject: [PATCH 1/2] custom extra metadata with scheming --- ckanext/scheming/plugins.py | 2 ++ ckanext/scheming/presets.json | 7 +++++++ .../templates/scheming/form_snippets/custom_extras.html | 5 +++++ .../scheming/package/snippets/additional_info.html | 5 +++++ 4 files changed, 19 insertions(+) create mode 100755 ckanext/scheming/templates/scheming/form_snippets/custom_extras.html diff --git a/ckanext/scheming/plugins.py b/ckanext/scheming/plugins.py index 0980a684..d7583b8e 100644 --- a/ckanext/scheming/plugins.py +++ b/ckanext/scheming/plugins.py @@ -260,6 +260,8 @@ def validate(self, context, data_dict, schema, action): composite_convert_fields = [] for field_list, destination, is_dataset in fg: for f in field_list: + if is_dataset and f['field_name'] == 'extras': + continue convert_this = is_dataset and f['field_name'] not in schema destination[f['field_name']] = get_validators( f, diff --git a/ckanext/scheming/presets.json b/ckanext/scheming/presets.json index efc0a51a..9e5b0534 100644 --- a/ckanext/scheming/presets.json +++ b/ckanext/scheming/presets.json @@ -152,6 +152,13 @@ "display_snippet": "select.html", "validators": "scheming_required scheming_choices" } + }, + { + "preset_name": "custom_extras", + "values": { + "form_snippet": "custom_extras.html", + "display_snippet": null + } } ] } diff --git a/ckanext/scheming/templates/scheming/form_snippets/custom_extras.html b/ckanext/scheming/templates/scheming/form_snippets/custom_extras.html new file mode 100755 index 00000000..851f1bab --- /dev/null +++ b/ckanext/scheming/templates/scheming/form_snippets/custom_extras.html @@ -0,0 +1,5 @@ + + + + +{%- snippet 'snippets/custom_form_fields.html', extras=data.extras, errors=errors, limit=3 -%} \ No newline at end of file diff --git a/ckanext/scheming/templates/scheming/package/snippets/additional_info.html b/ckanext/scheming/templates/scheming/package/snippets/additional_info.html index f8e0b9a6..b35e4dce 100644 --- a/ckanext/scheming/templates/scheming/package/snippets/additional_info.html +++ b/ckanext/scheming/templates/scheming/package/snippets/additional_info.html @@ -30,4 +30,9 @@ {{ _(pkg_dict.state) }} {% endif %} + + {% block extras scoped %} + {{ super() }} + {% endblock %} + {% endblock %} From 3aec73bb062ae41cce1489b3d1b4253b3e2124ac Mon Sep 17 00:00:00 2001 From: P DeKraker <47568003+pdekraker-epa@users.noreply.github.com> Date: Thu, 15 Jun 2023 10:19:46 -0400 Subject: [PATCH 2/2] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index b1c2ee74..76bdf5c2 100644 --- a/README.md +++ b/README.md @@ -504,6 +504,11 @@ JSON based input. Only JSON objects are supported. The input JSON will be loaded ``` markdown text area and display +```yaml + field_name: extras + preset: custom_extras +``` +space for user defined key, value pairs like standard CKAN input. When used the `field_name` must be extras. You may define your own presets by adding additional files to the `scheming.presets` [configuration setting](#configuration).