Add the ability to create an arbitrary schema for rendering elsewhere#403
Add the ability to create an arbitrary schema for rendering elsewhere#403mutantsan wants to merge 6 commits intockan:masterfrom
Conversation
| {%- endif -%} | ||
| {%- endfor -%} | ||
|
|
||
| {% snippet 'scheming/snippets/render_fields.html', fields=schema.dataset_fields, data=data, errors=errors, entity_type='dataset', object_type=dataset_type, set_fields_defaults=true %} |
There was a problem hiding this comment.
looks like licenses isn't passed through here or in the resource_form
|
@mutantsan sounds like a good idea, check the test failures and add some docs for the expected usage |
|
@wardi I've fixed the tests and wrote some doc. |
| entity_type - entity type | ||
| object_type - object type | ||
| set_fields_defaults - flag to set the default field values | ||
| {#} |
There was a problem hiding this comment.
this is cute but doing comments like this could lead to confusion about where the comment starts and ends
| {#} | ||
|
|
||
| {% for field in fields if field.form_snippet is not none %} | ||
| {% if field.field_name not in data and set_fields_defaults %} |
There was a problem hiding this comment.
All the other templates are indented with 2 spaces. Better to be consistent
| from setuptools import setup, find_packages | ||
|
|
||
| version = '3.0.0' | ||
| version = '3.0.1' |
There was a problem hiding this comment.
I'll bump the version number when doing a release
Right now I'm working on an extended admin panel and I need to create several configurational pages for different plugins. Since we are using
ckanext-schemingfor all of our CKAN projects, I assume it's a good idea to make it more flexible.The plugin is oriented toward creating a schema for predefined entity types (dataset, group & organization), but it already has the power to make much more. I suggest allowing defining arbitrary schemas with a unique
schema_id. This schema could be rendered as independent fields with arender_fields.htmlsnippet.It's defined as a separate extension inside
ckanext-scheming, that must be enabled to work with (same as other parts of the scheming). The schema follows the same format as group & organization schemas, except for theschema_idfield. That is a unique identifier of a schema. Example of a schema:When the schema is created and registered via CKAN config, we can fetch it with a
scheming_get_arbitrary_schemahelper. Then in a template, we can render a form like this:And get the next result:

I wrote tests but didn't update the documentation yet. I'm going to do it if we are fine with those changes.