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

AO3-6004 show hidden bookmarks on a bookmarkable to admins #4758

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

walshyb
Copy link
Contributor

@walshyb walshyb commented Mar 1, 2024

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6004

Purpose

Allows admins to show hidden bookmarks on a bookmarkable

Testing Instructions

  • Go to a bookmark index page with bookmarks
  • Hide a bookmark
  • When page refreshes, see "Make Bookmark Visible"
  • Clicking "Make Bookmark Visible" should refresh page and bring back bookmark

Credit

Brandon W (he/him/they/them)

@@ -61,7 +61,9 @@ def search
def index
if @bookmarkable
access_denied unless is_admin? || @bookmarkable.visible?
@bookmarks = @bookmarkable.bookmarks.is_public.paginate(page: params[:page], per_page: ArchiveConfig.ITEMS_PER_PAGE)
@bookmarks = @bookmarkable.bookmarks.is_public
@bookmarks += @bookmarkable.bookmarks.where(hidden_by_admin: true) if is_admin?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a bit weird how I'm doing it, but I didn't see another way to include bookmarks that have been hidden by admin and the public bookmarks.

Also should I add check for policy_and_abuse role?

Copy link
Member

Choose a reason for hiding this comment

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

Just a quick drive-by comment, not a thorough review:

  1. Let's not check the admin role, since I'm pretty sure we don't currently check it for, e.g., accessing hidden works directly. But maybe we should changes this two instances of is_admin? to logged_in_as_admin? -- this seems to be the only file where we use is_admin? and that's weird, imo.
  2. I'm guessing the problem with simply removing the is_public scope is you get private bookmarks as well as those hidden by admin? Would changing it to the not_private scope fix that? If not, I'd suggest defining a new scope in the bookmark model that will get public bookmarks, regardless of whether they're hidden by admin.

@@ -82,6 +82,7 @@ Feature: Admin Actions for Works, Comments, Series, Bookmarks
When I follow "Hide Bookmark"
And all indexing jobs have been run
Then I should see "Item has been hidden."
And I should see "Make Bookmark Visible"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I add another check to follow this and confirm visible from regular user end?

Copy link
Contributor

Choose a reason for hiding this comment

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

A regular user should not be able to see a hidden bookmark. But it would be nice to have a check that an admin can see the text of the hidden bookmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants