-
Notifications
You must be signed in to change notification settings - Fork 8
Handle Nested Resource Validation Errors #189
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
Merged
JVickery-TBS
merged 9 commits into
canada-v2.10
from
feature/handle-dataset-resource-validation
Feb 10, 2025
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1d65b0e
feat(dev): handle resource validation;
JVickery-TBS 6446a37
feat(misc): changelog;
JVickery-TBS 978f685
feat(dev): cont res validation;
JVickery-TBS 7c9d10d
feat(dev): resource errors;
JVickery-TBS edb59d8
Update ckan/logic/action/__init__.py
JVickery-TBS 632eebf
Update ckan/logic/action/__init__.py
JVickery-TBS dc4633c
refactor(dev): errors;
JVickery-TBS 97bcdc6
fix(templates): syntax;
JVickery-TBS 1864452
fix(templates): syntax;
JVickery-TBS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Now handles nested resource validation errors. Creating, updating, and deleting a resource can catch and handle validation errors from other resources in the dataset. |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| {# (canada fork only): handle all errors in resource actions #} | ||
| {# TODO: upstream contrib?? #} | ||
|
|
||
| {# | ||
| Builds a list of errors for the current form. | ||
|
|
||
| errors - A dict of field/message pairs. | ||
| type - The alert-* class that should be applied (default: "error") | ||
| classes - A list of classes to apply to the wrapper (default: []) | ||
|
|
||
| Example: | ||
|
|
||
| {% import 'macros/form.html' as form %} | ||
| {{ form.errors(error_summary, type="warning") }} | ||
|
|
||
| #} | ||
|
|
||
|
|
||
| {# (canada fork only): error -> danger BS version #} | ||
| {% macro dataset_errors(errors={}, type="danger", classes=[], pkg_name='', helpers={}) %} | ||
JVickery-TBS marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {% if errors %} | ||
| <div class="error-explanation alert alert-{{ type }}{{ " " ~ classes | join(' ') }}"> | ||
| <h3>{{_('Errors in dataset')}}</h3> | ||
JVickery-TBS marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {% if 'dataset' in errors and errors.dataset %} | ||
| {% set dataset_link = helpers.url_for('dataset.read', id=pkg_name) %} | ||
| <p>{{ _('The <a href="{}" target="_blank">dataset</a> contains errors:').format(dataset_link) }}</p> | ||
| <ul> | ||
| {% for field_id, field_errs in errors.dataset.items() %} | ||
| <li data-field-label="{{ field_id }}">{% if field_id %}{{ field_id }}{{_(':')}} {% endif %}{{ field_errs|join(', ') }}</li> | ||
| {% endfor %} | ||
| </ul> | ||
| {% endif %} | ||
| {% if 'resources' in errors and errors.resources %} | ||
| <p>{{ _('The dataset contains invalid resources:') }}</p> | ||
JVickery-TBS marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <ul> | ||
| {% for res_id, errs in errors.resources.items() %} | ||
| {% if not errs %} | ||
| {% continue %} | ||
| {% endif %} | ||
| <li><a href="{{ helpers.url_for('resource.read', id=pkg_name, resource_id=res_id) }}" target="_blank">{{ _('Resource') ~ ' ' ~ loop.index }}</a></li> | ||
JVickery-TBS marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <ul> | ||
| {% for field_id, field_errs in errs.items() %} | ||
| <li data-field-label="{{ field_id }}">{% if field_id %}{{ field_id }}{{_(':')}} {% endif %}{{ field_errs|join(', ') }}</li> | ||
| {% endfor %} | ||
| </ul> | ||
| {% endfor %} | ||
| </ul> | ||
| {% endif %} | ||
| </div> | ||
| {% endif %} | ||
| {% endmacro %} | ||
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.