Skip to content

Commit

Permalink
Change has_files in item-view to include only caption and supplementa…
Browse files Browse the repository at this point in the history
…l files in sections (#6200)

* Change has_files in item-view to include only caption and supplemental files in sections

* Code review: add new method to MO model, use any? instead select{}.present?
  • Loading branch information
Dananji authored Feb 20, 2025
1 parent 9cd5526 commit 21bedc6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/models/media_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,9 @@ def sections_with_files(tag: '*')
# TODO: Optimize this into a single solr query?
section_ids.select { |m| SpeedyAF::Proxy::MasterFile.find(m).supplemental_files(tag: tag).present? }
end

def sections_with_rendering_files?(tags)
tags.any? { |t| sections_with_files(tag: t).present? }
end

end
4 changes: 4 additions & 0 deletions app/presenters/speedy_af/proxy/media_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def sections_with_files(tag: '*')
sections.select { |master_file| master_file.supplemental_files(tag: tag).present? }.map(&:id)
end

def sections_with_rendering_files?(tags)
tags.any? { |t| sections_with_files(tag: t).present? }
end

def permalink_with_query(query_vars = {})
val = permalink
if val && query_vars.present?
Expand Down
2 changes: 1 addition & 1 deletion app/views/media_objects/_item_view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Unless required by applicable law or agreed to in writing, software distributed
timeline: { canCreate: (current_ability.can? :create, Timeline), content: lending_enabled?(@media_object) ? (render('timeline') if can_stream) : render('timeline') },
playlist: { canCreate: (current_ability.can? :create, Playlist), tab: render('add_to_playlist') },
cdl: { enabled: lending_enabled?(@media_object), can_stream: can_stream, embed: render('embed_checkout'), destroy: render('destroy_checkout') },
has_files: @media_object.supplemental_files.present? || @media_object.sections_with_files.present?,
has_files: @media_object.supplemental_files.present? || @media_object.sections_with_rendering_files?([nil, 'caption']),
has_transcripts: @media_object.sections_with_files(tag: 'transcript').present?
}
) %>
Expand Down

0 comments on commit 21bedc6

Please sign in to comment.