Skip to content

Commit

Permalink
Merge pull request #739 from nla/feat/blac-554-copyright-info
Browse files Browse the repository at this point in the history
feat: adds copyright info
  • Loading branch information
yetti authored Sep 17, 2023
2 parents 55a318d + d148d2a commit a4a2fdd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,15 @@ class CatalogController < ApplicationController
config.add_show_field "other_authors", label: "Other authors/contributors", accessor: :other_authors, helper_method: :other_author_search_list
config.add_show_field "also_titled", label: "Also Titled", accessor: :also_titled, helper_method: :list
config.add_show_field "terms_of_use", label: "Terms of Use", accessor: :terms_of_use, helper_method: :emphasized_list
config.add_show_field "copyright_info", label: "Copyright Information", accessor: :copyright_info, helper_method: :emphasized_list
config.add_show_field "available_from", label: "Available From", accessor: :available_from, helper_method: :unstyled_list
config.add_show_field "acknowledgement", label: "Acknowledgement", accessor: :acknowledgement, helper_method: :unstyled_list
config.add_show_field "exhibited", label: "Exhibited", accessor: :exhibited, helper_method: :list
config.add_show_field "govt_doc_number", label: "Govt. Doc. Number", accessor: :govt_doc_number, helper_method: :list
config.add_show_field "music_publisher_number", label: "Music Publisher Number", accessor: :music_publisher_number, helper_method: :list
config.add_show_field "related_records", label: "Related Records", accessor: :related_records, helper_method: :render_related_records_component
config.add_show_field "rights_information", label: "Rights information", accessor: :rights_information, helper_method: :url_list, component: StaffOnlyComponent
config.add_show_field "copyright_info", label: "Copyright", accessor: :copyright_status, helper_method: :render_copyright_component, if: ->(_controller, _config, document) do
config.add_show_field "copyright", label: "Copyright", accessor: :copyright_status, helper_method: :render_copyright_component, if: ->(_controller, _config, document) do
value = document.copyright_status
# if there is no contextMsg, there is no rights information from the copyright service
value.present? && value["contextMsg"].present?
Expand Down
8 changes: 5 additions & 3 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ def notes
memo_wise :notes

def copyright_status
copyright_info ||= get_copyright_status

# If no copyright info returned from the SOA
# don't show the component.
copyright_info.presence
get_copyright_status.presence
end
memo_wise :copyright_status

Expand Down Expand Up @@ -367,6 +365,10 @@ def terms_of_use
get_marc_derived_field("5403abcd", options: {alternate_script: false})
end

def copyright_info
get_marc_derived_field("542abcdefghijkmnopqrsu368", options: {alternate_script: false})
end

def other_authors
fetch("additional_author_with_relator_ssim", nil)
rescue KeyError
Expand Down
1 change: 1 addition & 0 deletions spec/files/marc/8663054.marcxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<record xmlns='http://www.loc.gov/MARC21/slim'><leader>02384ckc a2200469 i 4500</leader><controlfield tag='001'>8663054</controlfield><controlfield tag='005'>20230622101802.0</controlfield><controlfield tag='006'>m o c </controlfield><controlfield tag='007'>cr cn |||||n|n</controlfield><controlfield tag='008'>220714s2022 xx nnn o inzxx </controlfield><datafield ind1=' ' ind2=' ' tag='035'><subfield code='9'>(AuCNL)8663054</subfield></datafield><datafield ind1=' ' ind2=' ' tag='040'><subfield code='a'>ANL</subfield><subfield code='b'>eng</subfield><subfield code='e'>rda</subfield><subfield code='d'>ANL</subfield></datafield><datafield ind1=' ' ind2=' ' tag='042'><subfield code='a'>anuc</subfield></datafield><datafield ind1=' ' ind2=' ' tag='043'><subfield code='a'>u-at-vi</subfield></datafield><datafield ind1='1' ind2=' ' tag='100'><subfield code='a'>Henningham, Leigh,</subfield><subfield code='d'>1960-</subfield><subfield code='e'>photographer.</subfield></datafield><datafield ind1='1' ind2='0' tag='245'><subfield code='a'>Australian federal election campaign and polling places in Melbourne, Victoria, May 2022 / Leigh Henningham.</subfield></datafield><datafield ind1=' ' ind2='0' tag='264'><subfield code='c'>2022.</subfield></datafield><datafield ind1=' ' ind2=' ' tag='300'><subfield code='a'>1 online resource (30 photographs) :</subfield><subfield code='b'>TIFF files, colour</subfield></datafield><datafield ind1=' ' ind2=' ' tag='336'><subfield code='a'>still image</subfield><subfield code='2'>rdacontent</subfield></datafield><datafield ind1=' ' ind2=' ' tag='337'><subfield code='a'>computer</subfield><subfield code='2'>rdamedia</subfield></datafield><datafield ind1=' ' ind2=' ' tag='338'><subfield code='a'>online resource</subfield><subfield code='2'>rdacarrier</subfield></datafield><datafield ind1=' ' ind2=' ' tag='500'><subfield code='a'>Title devised by cataloguer based on information provided by photographer.</subfield></datafield><datafield ind1=' ' ind2=' ' tag='520'><subfield code='a'>Collection documenting polling places, election signage, candidates, campaign events, volunteers and voters in Melbourne, Victoria for the 2022 Australian federal election.</subfield></datafield><datafield ind1=' ' ind2=' ' tag='541'><subfield code='a'>Commissioned by the National Library of Australia, 2022.</subfield><subfield code='5'>ANL</subfield></datafield><datafield ind1=' ' ind2=' ' tag='542'><subfield code='f'>Copyright held by the National Library of Australia.</subfield></datafield><datafield ind1='1' ind2='0' tag='610'><subfield code='a'>Australia.</subfield><subfield code='b'>Parliament</subfield><subfield code='x'>Elections, 2022</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1='2' ind2='0' tag='610'><subfield code='a'>Australian Greens</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1='2' ind2='0' tag='610'><subfield code='a'>Australian Labor Party</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1='2' ind2='0' tag='610'><subfield code='a'>Liberal Party of Australia</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1='2' ind2='0' tag='610'><subfield code='a'>Pauline Hanson&apos;s One Nation</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1='2' ind2='0' tag='610'><subfield code='a'>United Australia Party</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Polling places</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Political posters</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Signs and signboards</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Voting</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Elections</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Political candidates</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Political campaigns</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='650'><subfield code='a'>Political parties</subfield><subfield code='z'>Victoria</subfield><subfield code='z'>Melbourne</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1=' ' ind2='0' tag='651'><subfield code='a'>Melbourne (Victoria)</subfield><subfield code='v'>Photographs.</subfield></datafield><datafield ind1='4' ind2='0' tag='856'><subfield code='z'>National Library of Australia digital collection item.</subfield><subfield code='u'>https://nla.gov.au/nla.obj-3075796665</subfield><subfield code='x'>fulltext</subfield></datafield><datafield ind1='4' ind2='2' tag='856'><subfield code='z'>Finding aid at National Library of Australia</subfield><subfield code='u'>https://nla.gov.au/nla.obj-3075796665/findingaid</subfield></datafield><datafield ind1='f' ind2='f' tag='999'><subfield code='i'>35df1d16-b7ab-525c-b586-dac248f3ddaa</subfield><subfield code='s'>60c66e24-6389-54fa-b12f-980fe3aecad2</subfield></datafield><datafield ind1='f' ind2='f' tag='952'><subfield code='a'>National Library of Australia</subfield><subfield code='b'>Parkes</subfield><subfield code='c'>Parkes</subfield><subfield code='d'>Use &apos;Online Access&apos; link in record (PICD)</subfield><subfield code='e'>PIC Online access #PIC/21070/1-30</subfield><subfield code='h'>Other scheme</subfield><subfield code='m'>013bb14d-1b1a-572e-a56d-a1b62273a9b2</subfield></datafield></record>
38 changes: 33 additions & 5 deletions spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@
end
end

describe "#copyright_info" do
subject(:copyright_info_value) do
describe "#copyright_status" do
subject(:copyright_status) do
document.copyright_status
end

Expand All @@ -221,8 +221,8 @@
)
.to_return(status: 200, body: IO.read("spec/files/copyright/service_response.xml").to_s, headers: {})

expect(copyright_info_value).not_to be_nil
expect(copyright_info_value["contextMsg"]).to eq "1.1"
expect(copyright_status).not_to be_nil
expect(copyright_status["contextMsg"]).to eq "1.1"
end

context "when no copyright info is returned by the SOA" do
Expand All @@ -238,7 +238,7 @@
)
.to_return(status: 502, body: "", headers: {})

expect(copyright_info_value).to be_nil
expect(copyright_status).to be_nil
end
end
end
Expand Down Expand Up @@ -1755,6 +1755,30 @@
end
end

describe "#copyright_info" do
context "when there is copyright information" do
subject(:copyright_info_value) do
document = described_class.new(marc_ss: copyright_info)
document.copyright_info
end

it "returns the copyright information" do
expect(copyright_info_value).to eq ["Copyright held by the National Library of Australia."]
end
end

context "when there is no copyright information" do
subject(:copyright_info_value) do
document = described_class.new(marc_ss: publication_date)
document.copyright_info
end

it "returns nil" do
expect(copyright_info_value).to be_nil
end
end
end

private

def single_series
Expand Down Expand Up @@ -2056,4 +2080,8 @@ def publication_date
def alternate_publication_date
load_marc_from_file 5976915
end

def copyright_info
load_marc_from_file 8663054
end
end

0 comments on commit a4a2fdd

Please sign in to comment.