diff --git a/.rubocop.yml b/.rubocop.yml index 9c4f81fbb..ce7aee34d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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' diff --git a/app/assets/javascripts/views-object.js b/app/assets/javascripts/views-object.js index 481dc5b69..a669f7ad8 100644 --- a/app/assets/javascripts/views-object.js +++ b/app/assets/javascripts/views-object.js @@ -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(); diff --git a/app/assets/stylesheets/custom-object-viewer.css.scss b/app/assets/stylesheets/custom-object-viewer.css.scss index 38db3bc2c..6661f4fd1 100644 --- a/app/assets/stylesheets/custom-object-viewer.css.scss +++ b/app/assets/stylesheets/custom-object-viewer.css.scss @@ -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%; diff --git a/app/controllers/dams_resource_controller.rb b/app/controllers/dams_resource_controller.rb index dd5ced76c..000914365 100644 --- a/app/controllers/dams_resource_controller.rb +++ b/app/controllers/dams_resource_controller.rb @@ -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'] diff --git a/app/helpers/dams_objects_helper.rb b/app/helpers/dams_objects_helper.rb index ccb904de8..534f19514 100644 --- a/app/helpers/dams_objects_helper.rb +++ b/app/helpers/dams_objects_helper.rb @@ -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 = "
#{get_attribution_note(document['otherNote_json_tesim'])}
".html_safe + 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 #--- diff --git a/app/views/dams_objects/_audio_viewer_complex.html.erb b/app/views/dams_objects/_audio_viewer_complex.html.erb index 71824025d..1d1c4cc33 100644 --- a/app/views/dams_objects/_audio_viewer_complex.html.erb +++ b/app/views/dams_objects/_audio_viewer_complex.html.erb @@ -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 %>