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

document: fix edition with notes #1062

Merged
merged 1 commit into from
Jun 23, 2020
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
7 changes: 2 additions & 5 deletions rero_ils/modules/documents/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from invenio_search.api import RecordsSearch

from .models import DocumentIdentifier, DocumentMetadata
from .utils import edition_format_text, note_format_text, \
publication_statement_text, series_format_text, title_format_text_head
from .utils import edition_format_text, publication_statement_text, \
series_format_text, title_format_text_head
from ..acq_order_lines.api import AcqOrderLinesSearch
from ..api import IlsRecord, IlsRecordsIndexer
from ..fetchers import id_fetcher
Expand Down Expand Up @@ -166,9 +166,6 @@ def dumps(self, **kwargs):
editions = dump.get('editionStatement', [])
for edition in editions:
edition['_text'] = edition_format_text(edition)
notes = dump.get('note', [])
if notes:
dump["notes_text"] = note_format_text(notes)
titles = dump.get('title', [])
bf_titles = list(filter(lambda t: t['type'] == 'bf:Title', titles))
for title in bf_titles:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,20 +476,6 @@
}
}
},
"note_text": {
"type": "object",
"properties": {
"accompanyingMaterial": {
"type": "text"
},
"general": {
"type": "text"
},
"otherPhysicalDetails": {
"type": "text"
}
}
},
"abstracts": {
"type": "text",
"fields": {
Expand Down
10 changes: 0 additions & 10 deletions rero_ils/modules/documents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ def edition_format_text(edition):
return edition_text


def note_format_text(notes):
"""Format note for _text."""
note_text = {}
for note in notes:
note_type = note.get('noteType')
note_text.setdefault(note_type, [])
note_text[note_type].append(note.get('label'))
return note_text


def display_alternate_graphic_first(language):
"""Display alternate graphic first.

Expand Down
13 changes: 9 additions & 4 deletions rero_ils/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
from .api import Document
from .dojson.contrib.unimarctojson import unimarc
from .utils import display_alternate_graphic_first, edition_format_text, \
localized_data_name, note_format_text, publication_statement_text, \
series_format_text, title_format_text_alternate_graphic, \
title_format_text_head, title_variant_format_text
localized_data_name, publication_statement_text, series_format_text, \
title_format_text_alternate_graphic, title_format_text_head, \
title_variant_format_text
from ..holdings.api import Holding
from ..items.models import ItemCirculationAction
from ..libraries.api import Library
Expand Down Expand Up @@ -258,7 +258,12 @@ def edition_format(editions):
@blueprint.app_template_filter()
def note_format(notes):
"""Format note for template."""
return note_format_text(notes)
notes_text = {}
for note in notes:
note_type = note.get('noteType')
notes_text.setdefault(note_type, [])
notes_text[note_type].append(note.get('label'))
return notes_text


@blueprint.app_template_filter()
Expand Down