Skip to content

Commit

Permalink
document: fix edition with notes
Browse files Browse the repository at this point in the history
* Removes notes_text from mapping.
* Creates a filter to display notes in detailed view.
* Closes rero#1036.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
  • Loading branch information
Alicia Zangger committed Jun 22, 2020
1 parent 2974aeb commit f35a608
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
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

0 comments on commit f35a608

Please sign in to comment.