mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-15 05:34:53 +08:00
f68d724202
* Rework experiment permissions [SCI-6054]
46 lines
1.5 KiB
Text
46 lines
1.5 KiB
Text
<%
|
|
query ||= nil
|
|
asset_read_allowed = false
|
|
file_name = asset.blob.metadata["asset_type"] ? asset.blob.metadata["name"] : asset.file_name
|
|
text = query.present? ? highlight(file_name, query.strip.split(/\s+/)) : file_name
|
|
%>
|
|
|
|
<% if asset.step %>
|
|
<% protocol = asset.step.protocol %>
|
|
<% if can_read_protocol_in_module?(protocol) ||
|
|
can_read_protocol_in_repository?(protocol) %>
|
|
<% asset_read_allowed = true %>
|
|
<a href="<%= rails_blob_path(asset.file, disposition: 'attachment') %>">
|
|
<%= text %>
|
|
</a>
|
|
<% else %>
|
|
<%= text %>
|
|
<% end %>
|
|
<% elsif asset.result %>
|
|
<% if can_read_experiment?(asset.result.my_module.experiment) %>
|
|
<% asset_read_allowed = true %>
|
|
<a href="<%= rails_blob_path(asset.file, disposition: 'attachment') %>">
|
|
<%= text %>
|
|
</a>
|
|
<% else %>
|
|
<%= text %>
|
|
<% end %>
|
|
<% elsif asset.repository_asset_value %>
|
|
<% if can_read_repository?(asset.repository_asset_value.repository_cell.repository_row.repository) %>
|
|
<% asset_read_allowed = true %>
|
|
<a href="<%= rails_blob_path(asset.file, disposition: 'attachment') %>">
|
|
<%= text %>
|
|
</a>
|
|
<% else %>
|
|
<%= text %>
|
|
<% end %>
|
|
<% else %>
|
|
<%= text %>
|
|
<% end %>
|
|
|
|
<!-- Display asset contents if it exists -->
|
|
<% if asset_read_allowed && asset.headline.present? && asset.headline.include?("<mark>") %>
|
|
<blockquote class="blockquote-search">
|
|
<p><%= highlight(sanitize_input(asset.headline), query.strip.split(/\s+/)) %></p>
|
|
</blockquote>
|
|
<% end %>
|