Skip to content

Commit

Permalink
dojson: fix physical description for page count
Browse files Browse the repository at this point in the history
* Adds the text "pages" for the pysical description of page count.
* Fixes the creation of physical descriptions if the page count is 0.

Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep authored and jma committed May 27, 2019
1 parent 04648ac commit 0c9f685
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion rero_ebooks/dojson/json/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,17 @@ def publisher_name(self, key, value):
@cantook_json.over('physical_description', 'page_count')
@utils.for_each_value
@utils.filter_values
@utils.ignore_value
def physical_description(self, key, value):
"""Physical description transformation.
extent (Number of physical pages, volumes...): Marc21 300 $a field.
"""
return {'extent': str(value)}
extent = None
if int(value) != 0:
pages = "{value} pages".format(value=value)
extent = {'extent': pages}
return extent


@cantook_json.over('summary', 'summary')
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_dojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_json_physical_description():
}
assert cantook_json.do(data) == {
'__order__': ['physical_description'],
'physical_description': [{'extent': '1234'}]
'physical_description': [{'extent': '1234 pages'}]
}


Expand Down

0 comments on commit 0c9f685

Please sign in to comment.