Skip to content

Commit

Permalink
document: adapt detail view for series statement
Browse files Browse the repository at this point in the history
* Creates a filter and a macro to display series statement.
* Displays series statement in detailed view.
* Creates filters to display partOf field.
* Displays partOf in detailed view.
* Corrects jsonschema for the editor display.
* Adds a fixture with periodical issuance subtype.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
Co-Authored-by: Peter Weber <peter.weber@rero.ch>
  • Loading branch information
2 people authored and AoNoOokami committed Jun 29, 2020
1 parent f021022 commit 23a9cc7
Show file tree
Hide file tree
Showing 20 changed files with 11,523 additions and 9,879 deletions.
9 changes: 5 additions & 4 deletions rero_ils/modules/documents/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from .models import DocumentIdentifier, DocumentMetadata
from .utils import edition_format_text, publication_statement_text, \
series_format_text, title_format_text_head
series_statement_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 @@ -161,10 +161,11 @@ def dumps(self, **kwargs):
for provision_activity in provision_activities:
provision_activity['_text'] = \
publication_statement_text(provision_activity)
# TODO: to by modified according to seriesStatement
series = dump.get('series', [])
series = dump.get('seriesStatement', [])
for series_element in series:
series_element["_text"] = series_format_text(series_element)
series_element["_text"] = series_statement_format_text(
series_element
)
editions = dump.get('editionStatement', [])
for edition in editions:
edition['_text'] = edition_format_text(edition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def marc21_to_part_of(self, key, value):
part_of['document'] = {
'$ref':
'https://ils.rero.ch/api/documents/{pid}'.format(
pid=linked_pid)
pid=linked_pid
)
}
subfield_v = not_repetitive(
unimarc.bib_id, key, value, 'v', default='').strip()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"bookFormat",
"dimensions",
"duration",
"illustrativeContent"
"illustrativeContent",
"issuance"
],
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -293,13 +294,16 @@
"messages": {
"patternMessage": "Should be in the following format: https://ils.rero.ch/api/documents/<PID>."
}
},
"templateOptions": {
"cssClass": "rero-ils-editor-max-width"
}
}
}
}
},
"numbering": {
"title": "Numbering",
"title": "Numberings",
"description": "For series, record only the volume. For journals, record every available information.",
"type": "array",
"minItems": 1,
Expand All @@ -320,17 +324,17 @@
"pattern": "^\\d{4}$"
},
"volume": {
"title": "volume",
"title": "Volume",
"type": "integer",
"minimum": 1
},
"issue": {
"title": "issue",
"title": "Issue",
"type": "string",
"minLength": 1
},
"pages": {
"title": "pages",
"title": "Pages",
"type": "string",
"pattern": "^\\d+(-\\d+)?$",
"form": {
Expand All @@ -339,11 +343,19 @@
}
},
"form": {
"hide": true
"templateOptions": {
"cssClass": "row"
}
}
}
}
}
},
"form": {
"hide": true,
"templateOptions": {
"cssClass": "rero-ils-editor-title"
}
}
},
"language": {
Expand Down Expand Up @@ -433,7 +445,10 @@
"label": "Integrating resource",
"value": "rdami:1004"
}
]
],
"templateOptions": {
"cssClass": "col-lg-6"
}
}
},
"subtype": {
Expand Down Expand Up @@ -494,9 +509,17 @@
"label": "Updating loose leaf",
"value": "updatingLoose-leaf"
}
]
],
"templateOptions": {
"cssClass": "col-lg-6"
}
}
}
},
"form": {
"templateOptions": {
"cssClass": "rero-ils-editor-title"
}
}
},
"translatedFrom": {
Expand Down Expand Up @@ -986,7 +1009,6 @@
"items": {
"title": "Color content",
"type": "string",
"default": "rdacc:1002",
"enum": [
"rdacc:1002",
"rdacc:1003"
Expand Down Expand Up @@ -1224,10 +1246,7 @@
"$ref": "#/definitions/language_script"
},
"form": {
"hide": true,
"templateOptions": {
"cssClass": "col-lg-7"
}
"hide": true
}
},
"subseriesStatement": {
Expand Down Expand Up @@ -1268,11 +1287,6 @@
}
}
}
},
"form": {
"templateOptions": {
"cssClass": "row"
}
}
},
"form": {
Expand Down Expand Up @@ -1301,7 +1315,6 @@
"noteType": {
"title": "Type of note",
"type": "string",
"default": "general",
"enum": [
"accompanyingMaterial",
"general",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,16 @@
}
}
}
},
"_text": {
"properties": {
"value": {
"type": "text"
},
"language": {
"type": "keyword"
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.

#}
{% from 'rero_ils/macros/macro.html' import dl, dl_dict, dl_list, div_json %}
{% from 'rero_ils/macros/macro.html' import dl, dl_dict, dl_language, dl_list, div_json %}

<dl class="row pt-4 ml-4">

Expand Down Expand Up @@ -57,9 +57,11 @@
{% endif %}
-->

<!-- SERIES -->
{% if record.series %}
{{ dl(_('Series'), record.series|series_format) }}
<!-- SERIES STATEMENT -->
{% if record.seriesStatement %}
{% for serie in record.seriesStatement %}
{{ dl_language(_('Series statement'), serie|series_format) }}
{% endfor %}
{% endif %}

<!-- PROVISION ACTIVITY -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,30 @@ <h3>

<!-- INTENDED AUDIENCE -->

<!-- IS PART OF
{% if record.is_part_of %}
{{ record.is_part_of }}
<!-- IS PART OF -->
{% if record.partOf %}
{% for partOf in record.partOf%}
{%- set data = partOf|part_of_format %}
<div class="row">
<dt class="col-auto">
{{ data.label }}
</dt>
<dd class="col-sm-10 col-md-10 mb-0">
<div class="row">
<a href="{{ url_for('invenio_records_ui.doc', viewcode=viewcode, pid_value=data.document_pid) }}">{{ data.title }}</a>
{% if data.numbering|length > 0 %}
<span>;</span>
<ul class="list-unstyled rero-ils-person mb-0 ml-1">
{% for element in data.numbering %}
<li>{{ element }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</dd>
</div>
{% endfor %}
{% endif %}
-->

<!-- ABSTRACT -->
{% if record.abstracts|length > 0 %}
Expand Down
70 changes: 62 additions & 8 deletions rero_ils/modules/documents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,68 @@ def publication_statement_text(provision_activity):
return statement_text


def series_format_text(serie):
"""Format series for template."""
output = []
if serie.get('name'):
output.append(serie.get('name'))
if serie.get('number'):
output.append(', ' + serie.get('number'))
return ''.join(str(x) for x in output)
def series_statement_format_text(serie_statement):
"""Format series statement for template."""
def get_title_language(data):
"""Get title and language."""
output = {}
for value in data:
language = value.get('language', 'default')
title = value.get('value', '')
language_title = output.get(language, [])
language_title.append(title)
output[language] = language_title
return output

serie_title = get_title_language(serie_statement.get('seriesTitle', []))
serie_enum = get_title_language(
serie_statement.get('seriesEnumeration', [])
)
subserie_data = []
for subserie in serie_statement.get('subseriesStatement', []):
subserie_title = get_title_language(subserie.get('subseriesTitle', []))
subserie_enum = get_title_language(
subserie.get('subseriesEnumeration', [])
)
subserie_data.append({'title': subserie_title, 'enum': subserie_enum})

intermediate_output = {}
for key, value in serie_title.items():
intermediate_output[key] = ', '.join(value)
for key, value in serie_enum.items():
value = ', '.join(value)
intermediate_value = intermediate_output.get(key, '')
intermediate_value = '{intermediate_value}; {value}'.format(
intermediate_value=intermediate_value,
value=value
)
intermediate_output[key] = intermediate_value
for intermediate_subserie in subserie_data:
for key, value in intermediate_subserie.get('title', {}).items():
value = ', '.join(value)
intermediate_value = intermediate_output.get(key, '')
intermediate_value = '{intermediate_value}. {value}'.format(
intermediate_value=intermediate_value,
value=value
)
intermediate_output[key] = intermediate_value
for key, value in subserie_enum.items():
value = ', '.join(value)
intermediate_value = intermediate_output.get(key, '')
intermediate_value = '{intermediate_value}; {value}'.format(
intermediate_value=intermediate_value,
value=value
)
intermediate_output[key] = intermediate_value

serie_statement_text = []
for key, value in intermediate_output.items():
if display_alternate_graphic_first(key):
serie_statement_text.insert(0, {'value': value, 'language': key})
else:
serie_statement_text.append({'value': value, 'language': key})

return serie_statement_text


def edition_format_text(edition):
Expand Down
Loading

0 comments on commit 23a9cc7

Please sign in to comment.