Repository navigation
[18.0][FIX] document_page_approval: 'Back to draft' button visible in draft and approved states - #655
Open
miquelrosell99 wants to merge 1 commit into
Open
miquelrosell99 wants to merge 1 commit into
miquelrosell99 wants to merge 1 commit into
Conversation
…revisions The button was visible whenever the user was owner or approver, in any state, and also for any user while the state was 'cancelled' or 'to approve'. action_draft() rejects anything but state 'cancelled', so users got a UserError from a visible button. Align the visibility with the server-side check: owner or approver, and state 'cancelled'.
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.
Problem
In the history form view, the Back to draft button uses:
invisible="(not am_i_owner or not am_i_approver) and (state not in ('cancelled', 'to approve'))"Because the two clauses are combined with
and, the button is visible whenever the user is owner or approver — in any state, includingdraftandapproved— and also for any user while the state iscancelled/to approve.However,
action_draft()raises aUserErrorunless the state iscancelled(document_page_approval/models/document_page_history.py:47), and requires the user to be owner or approver. So users routinely click a visible button that can only error out.Fix
Align the visibility expression with the server-side checks:
The button now shows only on
cancelledrevisions, for owners or approvers — matching the documented intent ("reopen if i am owner or approver") and theaction_draft()constraints.