Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate custom extra metadata #351

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions ckanext/scheming/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions ckanext/scheming/presets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@




{%- snippet 'snippets/custom_form_fields.html', extras=data.extras, errors=errors, limit=3 -%}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@
<td class="dataset-details">{{ _(pkg_dict.state) }}</td>
</tr>
{% endif %}

{% block extras scoped %}
{{ super() }}
{% endblock %}

{% endblock %}