Skip to content

Commit

Permalink
Merge branch 'main' into dont_crash_when_asking_if_can_create_any_work
Browse files Browse the repository at this point in the history
  • Loading branch information
cziaarm committed Sep 25, 2023
2 parents 0f74958 + d86db31 commit 101e7a8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions config/initializers/iiif_print.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,19 @@
collection: {}
}
end

# Override Hrax::WorkShowPresenter.authorized_item_ids to disallow "Pdf Page" work type from showing as members
Hyrax::WorkShowPresenter.class_eval do
private
# list of item ids to display is based on ordered_ids
def authorized_item_ids
@member_item_list_ids ||= begin
items = ordered_ids
items.delete_if { |m| !current_ability.can?(:read, m) } if Flipflop.hide_private_items?
#TODO a better way to detect if the user is signed in... if only there was a user_signed_in?
items.delete_if { |m| ActiveFedora::Base.where(id: m).first.human_readable_type == "Pdf Page" && current_ability.current_user.email.blank? }
items
end
end
end

0 comments on commit 101e7a8

Please sign in to comment.