app/presenters/hyrax/file_set_presenter.rb in hyrax-3.0.0.pre.rc3 vs app/presenters/hyrax/file_set_presenter.rb in hyrax-3.0.0.pre.rc4
- old
+ new
@@ -32,10 +32,14 @@
:depositor, :keyword, :title_or_label, :keyword,
:date_created, :date_modified, :itemtype,
:original_file_id,
to: :solr_document
+ def workflow
+ nil
+ end
+
def single_use_links
@single_use_links ||= SingleUseLink.where(item_id: id).map { |link| link_presenter_class.new(link) }
end
# The title of the webpage that shows this FileSet.
@@ -88,10 +92,11 @@
def parent
@parent_presenter ||= fetch_parent_presenter
end
def user_can_perform_any_action?
+ Deprecation.warn("We're removing Hyrax::FileSetPresenter.user_can_perform_any_action? in Hyrax 4.0.0; Instead use can? in view contexts.")
current_ability.can?(:edit, id) || current_ability.can?(:destroy, id) || current_ability.can?(:download, id)
end
private
@@ -101,9 +106,14 @@
def fetch_parent_presenter
ids = Hyrax::SolrService.query("{!field f=member_ids_ssim}#{id}", fl: Hyrax.config.id_field)
.map { |x| x.fetch(Hyrax.config.id_field) }
Hyrax.logger.warn("Couldn't find a parent work for FileSet: #{id}.") if ids.empty?
+ ids.each do |id|
+ doc = ::SolrDocument.find(id)
+ next if current_ability.can?(:edit, doc)
+ raise WorkflowAuthorizationException if doc.suppressed? && current_ability.can?(:read, doc)
+ end
Hyrax::PresenterFactory.build_for(ids: ids,
presenter_class: WorkShowPresenter,
presenter_args: current_ability).first
end
end