-
Notifications
You must be signed in to change notification settings - Fork 653
A03-7219 keep users with 'show the whole work by default' enabled in chapter by chapter mode when commenting #5524
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
Open
Dame-Zoom-A-Lot
wants to merge
3
commits into
otwcode:master
Choose a base branch
from
Dame-Zoom-A-Lot:AO3-7219_persist_work_preference_for_comment_redirect
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -55,8 +55,10 @@ def check_blocked | |
|
|
||
| def check_pseud_ownership | ||
| return unless params[:comment][:pseud_id] | ||
|
|
||
| pseud = Pseud.find(params[:comment][:pseud_id]) | ||
| return if pseud && current_user && current_user.pseuds.include?(pseud) | ||
|
|
||
| flash[:error] = ts("You can't comment with that pseud.") | ||
| redirect_to root_path | ||
| end | ||
|
|
@@ -180,14 +182,17 @@ def check_not_replying_to_spam | |
| def check_permission_to_review | ||
| parent = find_parent | ||
| return if logged_in_as_admin? || current_user_owns?(parent) | ||
|
|
||
| flash[:error] = ts("Sorry, you don't have permission to see those unreviewed comments.") | ||
| redirect_to logged_in? ? root_path : new_user_session_path(return_to: request.fullpath) | ||
| end | ||
|
|
||
| def check_permission_to_access_single_unreviewed | ||
| return unless @comment.unreviewed? | ||
|
|
||
| parent = find_parent | ||
| return if logged_in_as_admin? || current_user_owns?(parent) || current_user_owns?(@comment) | ||
|
|
||
| flash[:error] = ts("Sorry, that comment is currently in moderation.") | ||
| redirect_to logged_in? ? root_path : new_user_session_path(return_to: request.fullpath) | ||
| end | ||
|
|
@@ -384,7 +389,10 @@ def create | |
| elsif @comment.unreviewed? | ||
| redirect_to_all_comments(@commentable) | ||
| else | ||
| redirect_to_comment(@comment, { view_full_work: (params[:view_full_work] == "true"), page: params[:page] }) | ||
| # keep the user in chapter by chapter view if that was the view they were in when they commented | ||
| # An entire work view url would look like works/:id | ||
| user_chose_to_view_full_work = (current_user.try(:preference).try(:view_full_works) && request.referer&.match(/chapters/).nil?) | ||
| redirect_to_comment(@comment, { view_full_work: (params[:view_full_work] == "true" || user_chose_to_view_full_work), page: params[:page] }) | ||
| end | ||
| end | ||
| end | ||
|
|
@@ -689,8 +697,9 @@ def redirect_to_all_comments(commentable, options = {}) | |
| page: options[:page], | ||
| anchor: options[:anchor]) | ||
| else | ||
| if commentable.is_a?(Chapter) && (options[:view_full_work] || current_user.try(:preference).try(:view_full_works)) | ||
| commentable = commentable.work | ||
| if commentable.is_a?(Chapter) | ||
| user_chose_to_view_full_work = current_user.try(:preference).try(:view_full_works) && options[:view_full_work] != false | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be nice to have a unified way to see when a user wanted to to view full work vs chaptered view. But all the different helper methods and endpoints had slightly different ways we would need to use to identify them. |
||
| commentable = commentable.work if options[:view_full_work] || user_chose_to_view_full_work | ||
| end | ||
| redirect_to polymorphic_path(commentable, | ||
| options.slice(:show_comments, | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some whitespace only rubocop auto corrects