Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Add restricted note info to complex object view
Browse files Browse the repository at this point in the history
Fix failed test
  • Loading branch information
VivianChu committed May 1, 2018
1 parent 2b63101 commit 6546803
Show file tree
Hide file tree
Showing 10 changed files with 414 additions and 26 deletions.
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
5 changes: 3 additions & 2 deletions app/views/dams_objects/_audio_viewer_complex.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
dataForDynamicLoad = "{\"file_type\":\"audio\",\"display_file_path\":\"\",\"service_file_path\":\"#{wowzaURL}\"}"
%>
<% 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?%>
29 changes: 13 additions & 16 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_notice = grab_access_text(@document) if cannot? :update, @document %>

<section id="le-component">

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

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} %>
<%= render :partial => 'restricted_access', :locals => {:access_notice => access_notice } %>
<% if fileType == 'image' %>
<% if access_notice.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_notice.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_notice, :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_notice, :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_notice, :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_notice.nil?%>
<% elsif fileType == 'data' %>
<%= 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_notice.nil?%>
<% elsif fileType == '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_notice.nil?%>
<% else %>
<%= 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 +101,4 @@
<% end %>

</section>
</section>
4 changes: 2 additions & 2 deletions app/views/dams_objects/_document_viewer.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if defined?(filePath) and defined?(displayFilePath)%>
<% if access_notice.nil? and defined?(filePath) and defined?(displayFilePath)%>
<% viewFilePath = filePath.gsub('/download', '') %>
<%= link_to image_tag(displayFilePath, :alt => ''), viewFilePath %>
<% end %>
<% end %>
9 changes: 9 additions & 0 deletions app/views/dams_objects/_restricted_access.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% if cannot? :update, @document then %>
<% if access_notice %>
<div class="restricted-notice-complex">
<div>
<%= access_notice %>
</div>
</div>
<% end %>
<% 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 @@ -37,7 +37,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
6 changes: 2 additions & 4 deletions app/views/dams_objects/_video_viewer_complex.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
dataForDynamicLoad = "{\"file_type\":\"video\",\"display_file_path\":\"\",\"service_file_path\":\"#{wowzaURL}\"}"
%>
<% 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?%>
40 changes: 40 additions & 0 deletions spec/features/dams_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@
@audioComplexObj.add_file( 'dummy audio content 2', '_2_1.wav', 'test2.wav' )
@audioComplexObj.add_file( 'dummy audio content 3', '_3_1.mp3', 'test3.wav' )
@audioComplexObj.save!
solr_index (@unit.pid)
solr_index (@audioComplexObj.pid)
end
after(:all) do
Expand All @@ -703,6 +704,45 @@
end
end

describe "Curator 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 at research-data-curation@ucsd.edu'}
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 but not banner access text' 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.file-metadata', text: 'Access Restricted View')
expect(page).to_not have_selector('div.restricted-notice-complex', text: restricted_note)
end

scenario 'should see Restricted View access control info in other component' 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.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

0 comments on commit 6546803

Please sign in to comment.