Web 4461 save and publish button - #32
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughVersion 1.2.58 adds an opt-in ChangesSave and publish
Sequence Diagram(s)sequenceDiagram
participant Browser
participant CustomAddForm
participant publish_transition
participant publish
participant Workflow
Browser->>CustomAddForm: Submit Save and publish
CustomAddForm->>CustomAddForm: Create and store object
CustomAddForm->>publish_transition: Find allowed published transition
publish_transition-->>CustomAddForm: Return transition
CustomAddForm->>publish: Publish stored object
publish->>Workflow: Apply transition
Workflow-->>Browser: Return workflow result or warning
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/superpowers/specs/2026-08-07-save-and-publish-button-design.md`:
- Around line 42-43: Update the documented publish API and edit-form example to
include the required request argument used by publish in the implementation.
Ensure every shown invocation passes request alongside obj and transition so
copied examples do not raise TypeError.
- Around line 137-143: Update the documented minimum-coverage test module
reference from tests/test_save_and_publish.py to
src/imio/smartweb/common/tests/test_publish.py, preserving the listed test
scenarios.
In `@src/imio/smartweb/common/behaviors/configure.zcml`:
- Around line 22-27: Update the behavior metadata in the plone:behavior
declaration for imio.smartweb.save_and_publish to use the message factory from
imio.smartweb.locales for both title and description instead of literal strings,
preserving their current meanings and translation keys.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 17ada98e-8202-45a3-965e-18cf04f832fd
📒 Files selected for processing (8)
CHANGES.rstdocs/superpowers/specs/2026-08-07-save-and-publish-button-design.mdsrc/imio/smartweb/common/behaviors/configure.zcmlsrc/imio/smartweb/common/behaviors/publish.pysrc/imio/smartweb/common/browser/forms.pysrc/imio/smartweb/common/profiles/testing/types/Document.xmlsrc/imio/smartweb/common/tests/test_forms.pysrc/imio/smartweb/common/tests/test_publish.py
| def publish(obj, transition): | ||
| """Apply transition on obj, warning the user instead of failing.""" |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Update the documented publish API.
publish requires request in src/imio/smartweb/common/behaviors/publish.py so it can add a warning status message. The documented signature and edit-form example omit this argument. Copied code will raise TypeError.
Proposed documentation update
-def publish(obj, transition):
+def publish(obj, transition, request):
"""Apply transition on obj, warning the user instead of failing."""
...
-publish(self.context, self.publish_transition)
+publish(self.context, self.publish_transition, self.request)
...
-`publish(obj, transition)` est la troisième fonction
+`publish(obj, transition, request)` est la troisième fonctionAlso applies to: 93-103
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/superpowers/specs/2026-08-07-save-and-publish-button-design.md` around
lines 42 - 43, Update the documented publish API and edit-form example to
include the required request argument used by publish in the implementation.
Ensure every shown invocation passes request alongside obj and transition so
copied examples do not raise TypeError.
| `tests/test_save_and_publish.py`, couverture minimale 90 % : | ||
|
|
||
| - bouton présent sur un `Document` privé avec le behavior actif ; | ||
| - bouton absent sur un type sans le behavior (`Folder`) ; | ||
| - bouton absent sur un contenu déjà publié ; | ||
| - le bouton publie effectivement, depuis le formulaire d'édition ; | ||
| - le bouton crée puis publie, depuis le formulaire d'ajout. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the documented test module path.
The implemented test module is src/imio/smartweb/common/tests/test_publish.py. Replace tests/test_save_and_publish.py so the specification points to the test file in this PR.
🧰 Tools
🪛 LanguageTool
[typographical] ~140-~140: Caractère d’apostrophe incorrect.
Context: ...ton absent sur un type sans le behavior (Folder) ; - bouton absent sur un conten...
(APOS_INCORRECT)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/superpowers/specs/2026-08-07-save-and-publish-button-design.md` around
lines 137 - 143, Update the documented minimum-coverage test module reference
from tests/test_save_and_publish.py to
src/imio/smartweb/common/tests/test_publish.py, preserving the listed test
scenarios.
| <plone:behavior | ||
| name="imio.smartweb.save_and_publish" | ||
| title="Save and publish" | ||
| description="Add a 'Save and publish' button on add and edit forms." | ||
| provides=".publish.ISaveAndPublish" | ||
| /> |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use message-factory-backed behavior metadata.
Lines 24-25 add user-facing behavior labels as literal strings. Use messages from imio.smartweb.locales for the title and description so the behavior picker can translate them.
As per coding guidelines, use “the message factory from imio.smartweb.locales for all user-facing strings in Plone views and components.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/imio/smartweb/common/behaviors/configure.zcml` around lines 22 - 27,
Update the behavior metadata in the plone:behavior declaration for
imio.smartweb.save_and_publish to use the message factory from
imio.smartweb.locales for both title and description instead of literal strings,
preserving their current meanings and translation keys.
Source: Coding guidelines
Summary by CodeRabbit
New Features
Bug Fixes