Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import: fix get_contribution_link #3257

Merged
merged 1 commit into from
Feb 27, 2023
Merged
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
3 changes: 1 addition & 2 deletions rero_ils/dojson/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ def get_contribution_link(bibid, reroid, id, key):
if match and len(match.groups()) == 2 and key[:3] in _CONTRIBUTION_TAGS:
match_type = match.group(1).lower()
match_value = match.group(2)
match_type = match_type.replace('de-588', 'gnd')
# if we have a viafid, look for the contributor in MEF
if match_type == "viaf":
url = f'{mef_url}/mef/agents/?q=viaf_pid:{match_value}'
Expand Down Expand Up @@ -1996,7 +1995,7 @@ def build_identifier(data):
'RERO-RAMEAU': 'RERO-RAMEAU',
'IDREF': 'IdRef',
'GND': 'GND',
'DE-588': 'GND'
'DE-101': 'GND'
}
result = {}
data_0 = utils.force_list(data.get('0'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,18 @@ def perform_subdivisions(field):
value, subfield_code_per_tag[creator_tag_key]), '.', '.')
field_key = 'genreForm' if tag_key == '655' else config_field_key
subfields_0 = utils.force_list(value.get('0'))

cont_id = None
if subfields_0:
cont_id = subfields_0[0]
for subfield_0 in subfields_0:
if 'DE-101' in subfield_0:
cont_id = subfield_0.replace('DE-101', 'gnd')
break
if data_type in [DocumentSubjectType.PERSON,
DocumentSubjectType.ORGANISATION] and subfields_0:
ref = get_contribution_link(marc21.bib_id, marc21.rero_id,
subfields_0[0], key)
DocumentSubjectType.ORGANISATION] and cont_id:
ref = get_contribution_link(
marc21.bib_id, marc21.bib_id, cont_id, key)
if ref:
subject = {
'$ref': ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ def perform_subdivisions(field):
field_key = 'genreForm' if tag_key == '655' else config_field_key
subfields_0 = utils.force_list(value.get('0'))
if data_type in ['bf:Person', 'bf:Organisation'] and subfields_0:
ref = get_contribution_link(marc21.bib_id, marc21.rero_id,
subfields_0[0], key)
ref = get_contribution_link(
marc21.bib_id, marc21.bib_id, subfields_0[0], key)
if ref:
subject = {
'$ref': ref,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/documents/test_documents_dojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -5060,6 +5060,7 @@ def test_marc21_to_subjects_imported():
<datafield tag="919" ind1=" " ind2=" ">
<subfield code="a">Sekundarstufe</subfield>
<subfield code="0">(DE-588)4077347-4</subfield>
<subfield code="0">(DE-101)040773477</subfield>
<subfield code="2">gnd</subfield>
</datafield>
</record>
Expand Down