Repository navigation
Handle fieldset fields in the content rules control panel - #2056
Merged
Merged
Conversation
The edit and add forms of content rule conditions and actions are not group forms, so plone.autoform puts fields declared in a non-default fieldset on form.groups instead of form.fields. Getting, adding and updating a condition or action therefore ignored those fields, even though @Schema listed them. Merge the fields of all fieldsets into the form fields before reading or applying values. Closes #2016
Split add, get, update and delete into small dispatchers on the URL path segments, with private helpers for each operation. Share the CSRF protection, element lookup and edit form setup between them. Also add type hints and reST docstrings, raise NotFound when the add view of a rule or element cannot be found, and use f-strings for error messages. The API responses are unchanged.
|
@ericof thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment: To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
Member
Author
|
@jenkins-plone-org please run jobs |
plone.z3cform is not a declared dependency, and z3c.dependencychecker also scans imports guarded by TYPE_CHECKING. FormWrapper subclasses Products.Five's BrowserView, which Zope provides.
Member
Author
|
@jenkins-plone-org please run jobs |
Member
Author
|
News fragment is present, no idea why Mr. Roboto is complaining about it |
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.
Fields that a content rule condition or action declares in a non-default
fieldset(...)were listed in@schema, but@controlpanels/content-rulesdid not read or write their values.The edit and add forms of rule elements are not group forms, so
plone.autoformputs those fields onform.groupsinstead ofform.fields. The control panel only looked atform.fields, so:GET .../<rule>/action/<idx>(andcondition/<idx>) omitted their values;PATCHsilently ignored them;POST(adding an element) silently ignored them too. The issue doesn't mention this case, but it has the same cause.Changes
Fix (b81e887): a new
include_fieldset_fields(form)helper adds the fields of all fieldsets toform.fieldsbefore values are read or applied, inadd,getandupdate. It keeps the existing z3c.form path, soapplyChanges, theObjectModifiedEventand thetarget_folderUUID handling behave as before.Refactor (266a19d), with no behavior change:
add,get,updateanddeletebecome small dispatchers on the URL path segments, with private helpers for each operation;The generated http-examples are unchanged.
Tests
test_controlpanels_content_rules.pyregisters a test-only rule action whose schema has an "advanced" fieldset, in its own layer, so the documentedaddable_actionsdon't change. It covers GET, POST and PATCH of fieldset fields. All three tests fail without the fix (KeyError: 'extra_title').Full suite: 1409 tests, 7 failures. These are the pre-existing date/time failures I also get on
main.Closes #2016