-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add the ability to create an arbitrary schema for rendering elsewhere #403
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like licenses isn't passed through here or in the resource_form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is cute but doing comments like this could lead to confusion about where the comment starts and ends
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
{#} | ||
|
||
{% 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the other templates are indented with 2 spaces. Better to be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thanks
setup.py
Outdated
@@ -1,6 +1,6 @@ | |||
from setuptools import setup, find_packages | |||
|
|||
version = '3.0.0' | |||
version = '3.0.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll bump the version number when doing a release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
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-scheming
for 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.html
snippet.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_id
field. 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_schema
helper. 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.