Skip to content

Commit

Permalink
documents: add note for language
Browse files Browse the repository at this point in the history
* Closes rero#1867.

Co-Authored-by: Peter Weber <peter.weber@rero.ch>
  • Loading branch information
rerowep and rerowep committed Oct 5, 2021
1 parent 5b13154 commit fd23cda
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ def marc21_to_language(self, key, value):
'type': 'bf:Language'
})
lang_codes.append(lang_value)
# language note
fields_546 = marc21.get_fields(tag='546')
if fields_546:
subfields_546_a = marc21.get_subfields(fields_546[0], 'a')
if subfields_546_a:
language[0]['note'] = subfields_546_a[0]
# default provisionActivity if we have no 264
fields_264 = marc21.get_fields(tag='264')
valid_264 = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def marc21_to_part_of(self, key, value):
def unimarc_languages(self, key, value):
"""Get languages.
languages: 008 and 041 [$a, repetitive]
languages: 101 [$a, repetitive]
"""
languages = utils.force_list(value.get('a'))
to_return = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"additionalProperties": false,
"propertiesOrder": [
"type",
"value"
"value",
"note"
],
"properties": {
"type": {
Expand All @@ -40,6 +41,18 @@
},
"value": {
"$ref": "https://bib.rero.ch/schemas/common/languages-v0.0.1.json#/language"
},
"note": {
"title": "Note",
"type": "string",
"form": {
"type": "textarea",
"templateOptions": {
"itemCssClass": "col-lg-12",
"rows": 3,
"hide": true
}
}
}
},
"form": {
Expand All @@ -49,4 +62,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@
},
"value": {
"type": "keyword"
},
"note": {
"type": "text"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_documents_dojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def test_marc21_to_mode_of_issuance():

# pid: 001
def test_marc21_to_pid():
"""Test dojson marc21languages."""
"""Test dojson marc21pid."""

marc21xml = """
<record>
Expand Down Expand Up @@ -1313,6 +1313,9 @@ def test_marc21_to_language():
marc21xml = """
<record>
<controlfield tag="008">{field_008}</controlfield>
<datafield tag="546">
<subfield code="a">LANGUAGE NOTE</subfield>
</datafield>
</record>
""".format(
field_008='881005s1984 xxu|||||| ||||00|| |ara d'
Expand All @@ -1322,7 +1325,8 @@ def test_marc21_to_language():
assert data.get('language') == [
{
'type': 'bf:Language',
'value': 'ara'
'value': 'ara',
'note': 'LANGUAGE NOTE'
}
]

Expand Down

0 comments on commit fd23cda

Please sign in to comment.