Skip to content
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

Redirect edit pages for locked documents #4954

Merged
merged 4 commits into from Aug 6, 2019

Conversation

emmabeynon
Copy link
Contributor

For https://trello.com/c/QmVdXHrM/1026-disable-edit-in-the-whitehall-ui

Since we don't want locked documents to be edited in any way, in this PR we add a before hook to redirect any requests that could lead to a locked document being edited to the document's show page. A follow-up PR will deal with preventing users from being able to navigate to edit pages via the UI, but this focuses on the rare occasions that a user may land on an edit page (e.g. via a bookmark) or somehow make a request to edit a locked document and its associations.

Copy link
Member

@brucebolt brucebolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good 👍

@emmabeynon emmabeynon force-pushed the redirect-edit-pages-for-locked-documents branch 2 times, most recently from 9a27b1f to a879c60 Compare August 5, 2019 16:23
If a user accesses an page to edit a document when the document is locked, then
we redirect them back to the document index page to prevent potential edits and
reinforce the concept that locked documents cannot be edited.
When a user carries out various workflow actions on a document, they are
already redirected to the index page so we display an error message to
communicate why these actions have not been performed on a locked document
This ensures that if a user makes a request relating to an edition's various
associations, if the edition's document is locked then the user is redirected
to the document show page, preventing them from editing the document's
associations. Edition#forbid_editing_of_locked_documents has been extracted out
into the Admin:BaseController so that is can be reused by the other
controllers.
The Admin::NeedsController doesn't quite follow the same pattern as the other
controllers that are used for editing edition associations, insofar as it
doesn't perform a `find_edition` before hook, which means that an @edition
instance variable isn't set before the `forbid_editing_of_locked_documents`
hook is called, which it needs. This adds a `find_latest_edition` method to the
controller which allows us to set @edition for the locked documents hook as
well as for the update and edit actions. These actions also need @document set,
so we use `find_latest_edition` to set this as well.
@emmabeynon emmabeynon force-pushed the redirect-edit-pages-for-locked-documents branch from a879c60 to 810cffe Compare August 6, 2019 10:01
@emmabeynon emmabeynon merged commit 58627e4 into master Aug 6, 2019
@emmabeynon emmabeynon deleted the redirect-edit-pages-for-locked-documents branch August 6, 2019 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants