Pass dataset name to resource fields snippets#354
Merged
Conversation
Resource field snippets in the new form have no way of knowing the dataset id/name (if it's an edit form there is `data.package_id`). These changes are not the most elegant, because 1) they add a resource-specific key to the generic `form_field.html` and 2) they pass the dataset name instead of the id. This is because, annoyingly, upstream CKAN core only passes this from `new_resource.html` / `new_resource_not_draft.html` to `resource_form.html`, and not `pkg_dict`
wardi
reviewed
Jan 11, 2023
| entity_type='dataset', | ||
| object_type=dataset_type | ||
| object_type=dataset_type, | ||
| package_id=pkg_name |
Contributor
There was a problem hiding this comment.
a comment here about why we're passing the name as package_id would be good
Contributor
|
This is fine. If there's a core change to pass more data to the resource forms it should be driven by a specific need in another extension (or because it simplifies something in core), then we can mirror that change in scheming. |
Member
Author
|
Makes sense @wardi . I added a comment as requested |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@wardi this is just some proposal for discussion
Resource field snippets in the new form have no way of knowing the dataset id/name (if it's an edit form there is
data.package_id).These changes are not the most elegant, because 1) they add a resource-specific key to the generic
form_field.htmland 2) they pass the dataset name instead of the id.This is because, annoyingly, upstream CKAN core only passes the name from
new_resource.html/new_resource_not_draft.htmltoresource_form.html, and notpkg_dict, so that's the only thing available to ckanext-scheming to pass on.Should we patch the linked core templates to pass the whole
pkg_dicttoresource_form.html?Is there a simpler approach that I'm missing?
For context, we are using this in ckan/ckanext-validation#83, where we are creating a new frontend component to upload files that targets an endpoint that must know the dataset id to create the resource properly.