Skip to content
This repository was archived by the owner on Mar 24, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ Metrics/AbcSize:

Metrics/LineLength:
Max: 150

Rails/OutputSafety:
Exclude:
- 'app/helpers/dams_objects_helper.rb'

Style/SafeNavigation:
Exclude:
- 'app/helpers/dams_objects_helper.rb'
- 'lib/dams/controller_helper.rb'
6 changes: 6 additions & 0 deletions app/assets/javascripts/views-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ $(document).ready(function()
$(".simple-object, .first-component, .dams-sidebar").hide();
}

// Hide content if "restricted view notice" present
if($(".restricted-notice-complex").length)
{
$(".simple-object").hide();
}

// Show hidden "restricted notice" objects
$("#view-masked-object").click(function() {
$('.restricted-notice').hide();
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/custom-object-viewer.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ $complexFile: #AC6F2B !default;
.file-thumbnail img{margin-bottom: 20px;}

// Masked Objects (Restricted, Sensitive, etc.)
.restricted-notice
.restricted-notice, .restricted-notice-complex
{
background:#b1b1b1 url(https://library.ucsd.edu/assets/dams/site/restricted.png) no-repeat center center;
background-size:150%,150%;
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/dams_resource_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def show
end
end
@related_collections = related_collections_map facet_collection_names
else
@metadata_only = metadata_display?(@document['otherRights_tesim'])
end

@rdfxml = @document['rdfxml_ssi']
Expand Down
33 changes: 33 additions & 0 deletions app/helpers/dams_objects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,39 @@ def grabRestrictedText(data)

end

#---
# Check to see if an object has a "metadataDisplay or localDisplay otherRights"
#
# @return An HTML string if an object has a "metadataDisplay or localDisplay otherRights", nil otherwise
#---

def grab_access_text(document)
result = nil
access_group = document['read_access_group_ssim'] # "public" > "local" > "dams-curator" == "dams-rci" == default
data = document['otherRights_tesim']
unless data.nil? && access_group.nil?
if access_group.include?('local')
data.each do |datum|
if datum.include?('localDisplay') || datum.include?('metadataDisplay')
result = "<h3>Restricted View</h3><p>#{get_attribution_note(document['otherNote_json_tesim'])}</p>".html_safe

Choose a reason for hiding this comment

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

Rails/OutputSafety: Tagging a string as html safe may be a security risk.

end
end
end
end
result
end

def get_attribution_note(data)
result = 'Content not available. Access may granted for research purposes at the discretion of the UC San Diego Library. '
result += 'For more information please contact the '
unless data.nil?
data.each do |datum|
note = JSON.parse(datum)
result += note['value'] if note['type'].start_with?('local attribution')
end
end
result
end
#---
# Normalized rdf view from DAMS4 REST API
#---
Expand Down
6 changes: 4 additions & 2 deletions app/views/dams_objects/_audio_viewer_complex.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

dataForDynamicLoad = "{\"file_type\":\"audio\",\"display_file_path\":\"\",\"service_file_path\":\"#{wowzaURL}\"}"
%>
<%= render :partial => 'restricted_access', :locals => {:access_notice => access_notice } %>

<% if wowzaURL != nil %>
<% if access_notice.nil? && wowzaURL != nil %>

<div id="dams-audio-<%=componentIndex%>" data='<%=dataForDynamicLoad%>'>Loading the player...</div>

<% end %>
<%= render :partial => 'admin_download', :locals => {:downloadFilePath => downloadFilePath, :downloadDerivativePath => downloadDerivativePath } %>

<%= render :partial => 'admin_download', :locals => {:downloadFilePath => downloadFilePath, :downloadDerivativePath => downloadDerivativePath } if access_notice.nil?%>
31 changes: 16 additions & 15 deletions app/views/dams_objects/_complex_object_viewer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</div>
</div>
<% end %>
<% access_text = grab_access_text(@document) %>

<section id="le-component">

Expand Down Expand Up @@ -54,48 +55,48 @@

isFirstComponent = (i == 1) ? true : false
%>

<div id="component-<%= i %>" class="component <%= firstComponent if isFirstComponent %>" <%= loadFirstComponent if isFirstComponent %>>

<%= render :partial => 'shared/fields/title', :locals => {:componentIndex => i} %>

<% if fileType == 'image' %>

<%= render :partial => 'restricted_access', :locals => {:access_notice => access_text} %>
<% if access_text.nil? %>
<% zoom_file_path = zoom_path(ark, "#{i}") %>
<% dataForDynamicLoad = "{\"file_type\":\"image\",\"display_file_path\":\"#{display_file_path}\",\"service_file_path\":\"#{zoom_file_path}\",\"download_file_path\":\"#{download_file_path}\"}" %>

<div data='<%=dataForDynamicLoad%>'></div>
<% end %>
<%= render :partial => 'metadata_component', :locals => {:componentIndex => i} %>
<%= render :partial => 'admin_download', :locals => {:downloadFilePath => download_file_path, :downloadDerivativePath => service_file_path } %>
<%= render :partial => 'admin_download', :locals => {:downloadFilePath => download_file_path, :downloadDerivativePath => service_file_path } if access_text.nil?%>

<% elsif fileType == 'audio' %>

<%= render :partial => 'audio_viewer_complex', :locals => {:componentIndex => i, :downloadFilePath => download_file_path, :downloadDerivativePath => nil } %>
<%= render :partial => 'audio_viewer_complex', :locals => {:access_notice => access_text, :componentIndex => i, :downloadFilePath => download_file_path, :downloadDerivativePath => nil } %>
<%= render :partial => 'metadata_component', :locals => {:componentIndex => i} %>

<% elsif fileType == 'video' %>

<%= render :partial => 'video_viewer_complex', :locals => {:componentIndex => i, :downloadFilePath => download_file_path, :downloadDerivativePath => service_file_path } %>
<%= render :partial => 'video_viewer_complex', :locals => {:access_notice => access_text, :componentIndex => i, :downloadFilePath => download_file_path, :downloadDerivativePath => service_file_path } %>
<%= render :partial => 'metadata_component', :locals => {:componentIndex => i} %>

<% elsif fileType == 'document' %>

<%= render :partial => 'document_viewer', :locals => {:filePath => service_file_path, :displayFilePath => display_file_path, :downloadDerivativePath => service_file_path } %>
<%= render :partial => 'document_viewer', :locals => {:access_notice => access_text, :filePath => service_file_path, :displayFilePath => display_file_path, :downloadDerivativePath => service_file_path } %>
<%= render :partial => 'metadata_component', :locals => {:componentIndex => i, :fileMetadata => true, :fileName => service_file} %>
<%= render :partial => 'data_viewer', :locals => {:objectType => 'complex', :filePath => service_file_path, :downloadDerivativePath => service_file_path, :sourcefilePath => source_file_path } %>
<%= render :partial => 'data_viewer', :locals => {:objectType => 'complex', :filePath => service_file_path, :downloadDerivativePath => service_file_path, :sourcefilePath => source_file_path } if access_text.nil?%>

<% elsif fileType == 'data' %>

<%= render :partial => 'restricted_access', :locals => {:access_notice => access_text} %>
<%= render :partial => 'metadata_component', :locals => {:componentIndex => i, :fileMetadata => true, :fileName => service_file} %>
<%= render :partial => 'data_viewer', :locals => {:objectType => 'complex', :filePath => service_file_path, :downloadDerivativePath => service_file_path, :sourcefilePath => source_file_path } %>
<%= render :partial => 'data_viewer', :locals => {:objectType => 'complex', :filePath => service_file_path, :downloadDerivativePath => service_file_path, :sourcefilePath => source_file_path } if access_text.nil?%>
<% elsif fileType == 'text' %>
<%= render :partial => 'restricted_access', :locals => {:access_notice => access_text} %>
<%= render :partial => 'metadata_component', :locals => {:componentIndex => i, :fileMetadata => true, :fileName => service_file} %>
<%= render :partial => 'text_viewer', :locals => {:objectType => 'complex', :downloadFilePath => download_file_path, :downloadDerivativePath => service_file_path } %>
<%= render :partial => 'text_viewer', :locals => {:objectType => 'complex', :downloadFilePath => download_file_path, :downloadDerivativePath => service_file_path } if access_text.nil?%>
<% else %>

<%= render :partial => 'restricted_access', :locals => {:access_notice => access_text} %>
<%= render :partial => 'metadata_component', :locals => {:componentIndex => i} %>
<%= render :partial => 'default_viewer', :locals => {:objectType => 'complex'} %>

<%= render :partial => 'default_viewer', :locals => {:objectType => 'complex'} %>
<% end %>

</div>
Expand All @@ -104,4 +105,4 @@

<% end %>

</section>
</section>
3 changes: 2 additions & 1 deletion app/views/dams_objects/_document_viewer.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% if defined?(filePath) and defined?(displayFilePath)%>
<%= render :partial => 'restricted_access', :locals => {:access_notice => access_notice } %>
<% if access_notice.nil? and defined?(filePath) and defined?(displayFilePath)%>

<% viewFilePath = filePath.gsub('/download', '') %>

Expand Down
7 changes: 7 additions & 0 deletions app/views/dams_objects/_restricted_access.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% unless access_notice.nil? %>
<div class="restricted-notice-complex">
<div>
<%= access_notice %>
</div>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/dams_objects/_simple_object_viewer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<% when 'video-service' %>
<%= render :partial => 'video_viewer', :locals => {:filePath => service_file_path, :icon => display_file_path, :downloadFilePath => download_file_path, :downloadDerivativePath => download_derivative_path} %>
<% when 'document-service' %>
<%= render :partial => 'document_viewer', :locals => {:filePath => service_file_path, :displayFilePath => display_file_path, :downloadDerivativePath => download_derivative_path} %>
<%= render :partial => 'document_viewer', :locals => {:access_notice => nil, :filePath => service_file_path, :displayFilePath => display_file_path, :downloadDerivativePath => download_derivative_path} %>
<%= render :partial => 'metadata_data_file', :locals => {:fileName => service_file} %>
<%= render :partial => 'data_viewer', :locals => {:displayFilePath => display_file_path, :filePath => service_file_path, :objectType => 'simple', :pdfFilePath => pdf_file_path, :sourcefilePath => source_file_path} %>
<% when 'data-service' %>
Expand Down
7 changes: 3 additions & 4 deletions app/views/dams_objects/_video_viewer_complex.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
wowzaURL = grabWowzaURL(fieldData,objid,cmpid)
dataForDynamicLoad = "{\"file_type\":\"video\",\"display_file_path\":\"\",\"service_file_path\":\"#{wowzaURL}\"}"
%>
<%= render :partial => 'restricted_access', :locals => {:access_notice => access_notice } %>

<% if wowzaURL != nil %>

<% if access_notice.nil? && wowzaURL != nil %>
<video controls="controls" id="dams-video-<%=componentIndex%>" data='<%=dataForDynamicLoad%>'>Loading the player...</video>

<% end %>
<%= render :partial => 'admin_download', :locals => {:downloadFilePath => downloadFilePath, :downloadDerivativePath => downloadDerivativePath } %>
<%= render :partial => 'admin_download', :locals => {:downloadFilePath => downloadFilePath, :downloadDerivativePath => downloadDerivativePath } if access_notice.nil?%>
2 changes: 1 addition & 1 deletion config/deploy/qa.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set :stage, :qa
set :branch, 'develop'
set :branch, (ENV['BRANCH'] || fetch(:branch, 'develop'))
server 'lib-hydrahead-qa.ucsd.edu', user: 'conan', roles: %w{web app db sitemap_noping}
server 'lib-hydratail-qa.ucsd.edu', user: 'conan', roles: %w{web app db sitemap_noping}
set :rails_env, "qa"
Expand Down
10 changes: 10 additions & 0 deletions lib/dams/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -882,5 +882,15 @@ def referrer_controller( request )
end
end
end

def metadata_display?(data)
result = false
unless data.nil?
data.each do |datum|
result = true if datum.include?('localDisplay') || datum.include?('metadataDisplay')
end
end
result
end
end
end
5 changes: 2 additions & 3 deletions spec/features/access_control_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
visit catalog_index_path( {:q => 'object'} )
expect(page).to have_selector('h3', 'Public Object')
expect(page).to have_no_content('Curator Object')
expect(page).to have_no_content('Local Object')
expect(page).to have_content('Local Object')
expect(page).to have_no_content('Hidden Object')
end
scenario 'anonymous user viewing public object' do
Expand All @@ -50,8 +50,7 @@
end
scenario 'anonymous user viewing local object' do
visit dams_object_path @localObj.pid
expect(page).to have_selector('h1','You are not allowed to view this page.')
expect(page).to have_no_content('Local Object')
expect(page).to have_content('Local Object')
end
scenario 'anonymous user viewing file attached to hidden object' do
visit file_path( @hiddenObj, '_1.txt' )
Expand Down
40 changes: 40 additions & 0 deletions spec/features/dams_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,46 @@
end
end

describe "User wants to view a metadata-only complex object" do
let(:restricted_note) {'Restricted View Content not available. Access may granted for research purposes at the discretion of the UC San Diego Library. For more information please contact the Research Data Curation Program, UC San Diego, La Jolla, 92093-0175 (https://lib.ucsd.edu/rdcp)'}
before do
@otherRight = DamsOtherRight.create pid: 'xx58718348', permissionType: "metadataDisplay"
@metadataOnlyCollection = DamsProvenanceCollection.create pid: 'xx91824453', titleValue: "Test UCSD IP only Collection with metadata-only visibility", visibility: "local"
@metadataOnlyObj = DamsObject.create(pid: "xx99999999")
@metadataOnlyObj.damsMetadata.content = File.new('spec/fixtures/damsComplexObject10.rdf.xml').read
@metadataOnlyObj.save!
solr_index @otherRight.pid
solr_index @metadataOnlyCollection.pid
solr_index @metadataOnlyObj.pid
Capybara.javascript_driver = :poltergeist
Capybara.current_driver = Capybara.javascript_driver
sign_in_developer
end

after do
@otherRight.delete
@metadataOnlyCollection.delete
@metadataOnlyObj.delete
end

scenario 'should see Restricted View access control information' do
visit dams_object_path @metadataOnlyObj.pid
expect(page).to have_selector('#component-pager-label', :text=>'Component 1 of 4')
expect(page).to have_content('Interval 1 (dredge, rock)')
expect(page).to have_selector('div.restricted-notice-complex', text: restricted_note)
expect(page).to have_selector('div.file-metadata', text: 'Access Restricted View')
end

scenario 'should see Restricted View access control info in other component when clicking on navigation arrow' do
visit dams_object_path @metadataOnlyObj.pid
click_button 'component-pager-forward'
find('#component-pager-label').should have_content('Component 2 of 4')
expect(page).to have_content('Files')
expect(page).to have_selector('div.restricted-notice-complex', text: restricted_note)
expect(page).to have_selector('div.file-metadata', text: 'Access Restricted View')
end
end

describe "curator embargoed object view" do
before do
@otherRights = DamsOtherRight.create pid: 'zz58718348', permissionType: "metadataDisplay", basis: "fair use",
Expand Down
Loading