diff --git a/sonar/config.py b/sonar/config.py
index 28822a9e..4ccdf433 100644
--- a/sonar/config.py
+++ b/sonar/config.py
@@ -278,13 +278,13 @@ def _(x):
'documents': dict(
aggs=dict(
institution=dict(terms=dict(field='institution.pid')),
- language=dict(terms=dict(field='languages.language')),
+ language=dict(terms=dict(field='languages.name')),
author=dict(terms=dict(field='facet_authors')),
subject=dict(terms=dict(field='facet_subjects'))
),
filters={
_('institution'): terms_filter('institution.pid'),
- _('language'): terms_filter('languages.language'),
+ _('language'): terms_filter('languages.name'),
_('author'): terms_filter('facet_authors'),
_('subject'): terms_filter('facet_subjects'),
}
diff --git a/sonar/modules/config.py b/sonar/modules/config.py
index 057d7ad6..80e0884d 100644
--- a/sonar/modules/config.py
+++ b/sonar/modules/config.py
@@ -9,3 +9,18 @@
"""SONAR configuration."""
SONAR_APP_API_URL = 'https://localhost:5000/api/'
+
+SONAR_APP_LANGUAGES_MAP = dict(
+ fre='fr',
+ ger='de',
+ eng='en',
+ ita='it',
+ spa='sp',
+ ara='ar',
+ chi='zh',
+ lat='la',
+ heb='iw',
+ jpn='ja',
+ por='pt',
+ rus='ru'
+)
diff --git a/sonar/modules/documents/dojson/contrib/marc21tojson/model.py b/sonar/modules/documents/dojson/contrib/marc21tojson/model.py
index 19ee78c1..bf09d69c 100644
--- a/sonar/modules/documents/dojson/contrib/marc21tojson/model.py
+++ b/sonar/modules/documents/dojson/contrib/marc21tojson/model.py
@@ -12,26 +12,29 @@
import sys
import requests
+from babel import Locale
from dojson import Overdo, utils
+from flask import current_app
marc21tojson = Overdo()
def remove_punctuation(data):
"""Remove punctuation from data."""
- try:
- if data[-1:] == ',':
- data = data[:-1]
- if data[-2:] == ' :':
- data = data[:-2]
- if data[-2:] == ' ;':
- data = data[:-2]
- if data[-2:] == ' /':
- data = data[:-2]
- if data[-2:] == ' -':
- data = data[:-2]
- except Exception:
- pass
+ if not isinstance(data, str):
+ return data
+
+ if data[-1:] == ',':
+ data = data[:-1]
+ if data[-2:] == ' :':
+ data = data[:-2]
+ if data[-2:] == ' ;':
+ data = data[:-2]
+ if data[-2:] == ' /':
+ data = data[:-2]
+ if data[-2:] == ' -':
+ data = data[:-2]
+
return data
@@ -150,7 +153,12 @@ def marc21_to_languages(self, key, value):
languages: 008 and 041 [$a, repetitive]
"""
language = value.strip()[35:38]
- to_return = [{'language': language}]
+ code = current_app.config.get('SONAR_APP_LANGUAGES_MAP')[language]
+
+ to_return = [{
+ 'code': language,
+ 'name': Locale(code).get_language_name().capitalize()
+ }]
return to_return
@@ -165,7 +173,7 @@ def marc21_to_translatedFrom(self, key, value):
languages = self.get('languages', [])
unique_lang = []
if languages != []:
- unique_lang.append(languages[0]['language'])
+ unique_lang.append(languages[0]['code'])
language = value.get('a')
if language:
@@ -175,7 +183,11 @@ def marc21_to_translatedFrom(self, key, value):
languages = []
for lang in unique_lang:
- languages.append({'language': lang})
+ code = current_app.config.get('SONAR_APP_LANGUAGES_MAP')[lang]
+ languages.append({
+ 'code': lang,
+ 'name': Locale(code).get_language_name().capitalize()
+ })
self['languages'] = languages
translated = value.get('h')
@@ -327,7 +339,10 @@ def marc21_to_abstracts(self, key, value):
abstract: [520$a repetitive]
"""
- return ', '.join(utils.force_list(value.get('a')))
+ return {
+ 'language': value.get('9'),
+ 'value': ', '.join(utils.force_list(value.get('a')))
+ }
@marc21tojson.over('identifiers', '^020..')
@@ -380,6 +395,7 @@ def marc21_to_is_part_of(self, key, value):
@marc21tojson.over('subjects', '^6....')
+@utils.for_each_value
@utils.ignore_value
def marc21_to_subjects(self, key, value):
"""Get subjects.
@@ -387,4 +403,4 @@ def marc21_to_subjects(self, key, value):
subjects: 6xx [duplicates could exist between several vocabularies,
if possible deduplicate]
"""
- return value.get('a').split(' ; ')
+ return dict(language=value.get('9'), value=value.get('a').split(' ; '))
diff --git a/sonar/modules/documents/jsonschemas/documents/document-v1.0.0.json b/sonar/modules/documents/jsonschemas/documents/document-v1.0.0.json
index 99589be0..c92cd43c 100644
--- a/sonar/modules/documents/jsonschemas/documents/document-v1.0.0.json
+++ b/sonar/modules/documents/jsonschemas/documents/document-v1.0.0.json
@@ -26,8 +26,38 @@
"type": "array",
"minItems": 1,
"items": {
- "type": "string",
- "minLength": 3
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "language", "value"
+ ],
+ "properties": {
+ "language": {
+ "title": "Abstract language",
+ "description": "Language of abstract.",
+ "type": "string",
+ "enum": [
+ "fre",
+ "ger",
+ "eng",
+ "ita",
+ "spa",
+ "ara",
+ "chi",
+ "lat",
+ "heb",
+ "jpn",
+ "por",
+ "rus"
+ ]
+ },
+ "value": {
+ "title": "Abstract content",
+ "description": "Text content of abstract.",
+ "type": "string",
+ "minLength": 1
+ }
+ }
}
},
"identifiers": {
@@ -67,15 +97,21 @@
"items": {
"type": "object",
"required": [
- "language"
+ "name", "code"
],
"properties": {
- "language": {
- "title": "Language",
- "description": "Required. Language of the resource, primary or not.",
+ "name": {
+ "title": "Language name",
+ "description": "Name value of the language.",
+ "type": "string",
+ "default": "Français"
+ },
+ "code": {
+ "title": "Bibliographic language code",
+ "description": "Bibligraphic code of language.",
"type": "string",
"default": "fre",
- "validationMessage": "Required. Language of the resource, primary or not.",
+ "validationMessage": "Bibliographic language code is required.",
"enum": [
"fre",
"ger",
@@ -161,10 +197,40 @@
"title": "Subject",
"description": "Subject of the resource.",
"type": "array",
- "minItems": 1,
+ "additionalProperties": false,
"items": {
- "type": "string",
- "minLength": 1
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "language", "value"
+ ],
+ "properties": {
+ "language": {
+ "title": "Subject language",
+ "description": "Language of subject.",
+ "type": "string",
+ "enum": [
+ "fre",
+ "ger",
+ "eng",
+ "ita",
+ "spa",
+ "ara",
+ "chi",
+ "lat",
+ "heb",
+ "jpn",
+ "por",
+ "rus"
+ ]
+ },
+ "value": {
+ "title": "Subjects list",
+ "description": "A list of subjects.",
+ "type": "array",
+ "minLength": 1
+ }
+ }
}
},
"notes": {
diff --git a/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json b/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json
index 77ff0583..fdfe07f7 100644
--- a/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json
+++ b/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json
@@ -15,11 +15,16 @@
"type": "text"
},
"abstracts": {
- "type": "text"
+ "type": "object"
},
"subjects": {
- "type": "text",
- "copy_to": "facet_subjects"
+ "type": "object",
+ "properties": {
+ "value": {
+ "type": "text",
+ "copy_to": "facet_subjects"
+ }
+ }
},
"facet_subjects": {
"type": "keyword"
@@ -41,7 +46,7 @@
"languages": {
"type": "object",
"properties": {
- "language": {
+ "name": {
"type": "keyword"
}
}
diff --git a/sonar/modules/documents/marshmallow/json.py b/sonar/modules/documents/marshmallow/json.py
index bcc61039..9c6782f8 100644
--- a/sonar/modules/documents/marshmallow/json.py
+++ b/sonar/modules/documents/marshmallow/json.py
@@ -21,7 +21,7 @@ class DocumentMetadataSchemaV1(StrictKeysMixin):
pid = PersistentIdentifier()
title = SanitizedUnicode(required=True)
- abstracts = fields.List(fields.Str())
+ abstracts = fields.List(fields.Dict())
authors = fields.Dict(dump_only=True)
institution = fields.Dict(dump_only=True)
diff --git a/sonar/modules/documents/static/templates/documents/search_ui/results.html b/sonar/modules/documents/static/templates/documents/search_ui/results.html
index a696109e..253cf61f 100644
--- a/sonar/modules/documents/static/templates/documents/search_ui/results.html
+++ b/sonar/modules/documents/static/templates/documents/search_ui/results.html
@@ -8,11 +8,13 @@
-->
-
{{record.metadata.institution.name}}
-
-
{{author.name}}
-
- {{record.metadata.abstracts[0]}}
+
{{ record.metadata.institution.name }}
+
+
{{ author.name }}
+
+ {{ abstract.value }}
\ No newline at end of file
diff --git a/sonar/modules/documents/templates/documents/record.html b/sonar/modules/documents/templates/documents/record.html
index e9089863..45f628c6 100644
--- a/sonar/modules/documents/templates/documents/record.html
+++ b/sonar/modules/documents/templates/documents/record.html
@@ -9,6 +9,8 @@
{%- extends config.RECORDS_UI_BASE_TEMPLATE %}
+{% from 'sonar/macros/macro.html' import dl %}
+
{%- macro record_content(data) %}
{% for key, value in data.items() recursive %}
@@ -38,9 +40,62 @@
{%- endmacro %}
{%- block page_body %}
-{{record.title}}
+
+{% set record = record.replace_refs() %}
+{{ record.title }}
+{% if record.institution %}
+{{ record.institution.name }}
+{% endif %}
+
+
+
+
+ {% if record.authors|length > 0 %}
+ {{ dl(_('Authors'), record.authors | authors_format) }}
+ {% endif %}
+
+
+ {% if record.abstracts|length > 0 %}
+ {{ dl(_('Abstract'), record.abstracts | translate_content(current_i18n.language) | nl2br ) }}
+ {% endif %}
+
+
+ {% if record.extent or record.otherMaterialCharacteristics or record.formats %}
+ {% set formats = ', '.join(record.formats) %}
+ {% set description = ', '.join([record.extent, record.otherMaterialCharacteristics, formats]|select) %}
+ {{ dl(_('Physical description'), description) }}
+ {% endif %}
+
+
+ {% if record.subjects|length > 0 %}
+ {{ dl(_('Subject'), record.subjects | translate_content(current_i18n.language) | join(', ')) }}
+ {% endif %}
+
+
+ {% if record.languages|length > 0 %}
+ {{ dl(_('Language'), record.languages[0].name) }}
+ {% endif %}
+
+
+ {% if record.notes|length > 0 %}
+ {{ dl(_('Notes'), record.notes | join('\n') | nl2br) }}
+ {% endif %}
+
+
+ {% if record.identifiers %}
+ {% if record.identifiers.isbn %}
+ {{ dl(_('ISBN'), record.identifiers.isbn) }}
+ {% endif %}
+ {% endif %}
+
+
+ {% set link = url_for('invenio_records_ui.document', pid_value=record.pid, ir=g.ir|default('sonar'), _external=True) %}
+ {{ dl(_('Permalink'), '' + link + '') }}
+
+
{%- endblock %}
diff --git a/sonar/modules/documents/views.py b/sonar/modules/documents/views.py
index ded5fa41..5e89db4b 100644
--- a/sonar/modules/documents/views.py
+++ b/sonar/modules/documents/views.py
@@ -10,15 +10,13 @@
from __future__ import absolute_import, print_function
-from flask import Blueprint, g, render_template
-
-blueprint = Blueprint(
- 'documents',
- __name__,
- template_folder='templates',
- static_folder='static',
- url_prefix='/organization/'
-)
+from flask import Blueprint, current_app, g, render_template
+
+blueprint = Blueprint('documents',
+ __name__,
+ template_folder='templates',
+ static_folder='static',
+ url_prefix='/organization/')
"""Blueprint used for loading templates and static assets
The sole purpose of this blueprint is to ensure that Invenio can find the
@@ -59,3 +57,82 @@ def detail(pid, record, template=None, **kwargs):
"""Search details."""
g.ir = kwargs.get('ir')
return render_template('documents/record.html', pid=pid, record=record)
+
+
+@blueprint.app_template_filter()
+def authors_format(authors):
+ """Format authors for template."""
+ output = []
+ for author in authors:
+ output.append(author['name'])
+
+ return ' ; '.join(output)
+
+
+@blueprint.app_template_filter()
+def nl2br(string):
+ r"""Replace \n to
."""
+ return string.replace('\n', '
')
+
+
+@blueprint.app_template_filter()
+def translate_content(records, locale, value_key='value'):
+ """Translate record data for the given locale."""
+ if not records:
+ return None
+
+ lang = get_bibliographic_code_from_language(locale)
+
+ found = [
+ abstract for abstract in records
+ if abstract['language'] == lang
+ ]
+
+ record = None
+
+ if found:
+ record = found[0]
+ else:
+ record = records[0]
+
+ if value_key not in record:
+ raise Exception(
+ 'Value key "{value_key}" in {record} does not exist'.format(
+ value_key=value_key, record=record))
+
+ return record[value_key]
+
+
+def get_language_from_bibliographic_code(language_code):
+ """Return language code from bibliographic language.
+
+ For example, get_language_code_from_bibliographic_language('ger') will
+ return 'de'
+
+ :param language_code: Bibliographic language
+ :return str
+ """
+ languages_map = current_app.config.get('SONAR_APP_LANGUAGES_MAP')
+
+ if language_code not in languages_map:
+ raise Exception('Language code not found for "{language_code}"'.format(
+ language_code=language_code))
+
+ return languages_map[language_code]
+
+
+def get_bibliographic_code_from_language(language_code):
+ """Return bibliographic language code from language.
+
+ For example, get_bibliographic_code_from_language("de") will
+ return "ger"
+
+ :param language_code: Bibliographic language
+ :return str
+ """
+ for key, lang in current_app.config.get('SONAR_APP_LANGUAGES_MAP').items():
+ if lang == language_code:
+ return key
+
+ raise Exception('Language code not found for "{language_code}"'.format(
+ language_code=language_code))
diff --git a/sonar/theme/templates/sonar/macros/macro.html b/sonar/theme/templates/sonar/macros/macro.html
new file mode 100644
index 00000000..3600c675
--- /dev/null
+++ b/sonar/theme/templates/sonar/macros/macro.html
@@ -0,0 +1,8 @@
+{% macro dl(title, content) %}
+
+ {{ title }}:
+
+
+ {{ content|safe }}
+
+{% endmacro %}
\ No newline at end of file
diff --git a/sonar/translations/de/LC_MESSAGES/messages.po b/sonar/translations/de/LC_MESSAGES/messages.po
index 2b23d48b..19cc36da 100644
--- a/sonar/translations/de/LC_MESSAGES/messages.po
+++ b/sonar/translations/de/LC_MESSAGES/messages.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: sonar 0.0.1\n"
"Report-Msgid-Bugs-To: software@rero.ch\n"
-"POT-Creation-Date: 2019-07-22 13:54+0200\n"
+"POT-Creation-Date: 2019-07-22 16:12+0200\n"
"PO-Revision-Date: 2019-06-13 10:45+0200\n"
"Last-Translator: FULL NAME \n"
"Language: de\n"
@@ -62,6 +62,38 @@ msgstr "Beste Übereinstimmung"
msgid "Most recent"
msgstr "Neueste"
+#: sonar/modules/documents/templates/documents/record.html:58
+msgid "Authors"
+msgstr "Autoren"
+
+#: sonar/modules/documents/templates/documents/record.html:63
+msgid "Abstract"
+msgstr "Zusammenfassung"
+
+#: sonar/modules/documents/templates/documents/record.html:70
+msgid "Physical description"
+msgstr "Physische Beschreibung"
+
+#: sonar/modules/documents/templates/documents/record.html:75
+msgid "Subject"
+msgstr "Subjekt"
+
+#: sonar/modules/documents/templates/documents/record.html:80
+msgid "Language"
+msgstr "Sprache"
+
+#: sonar/modules/documents/templates/documents/record.html:85
+msgid "Notes"
+msgstr "Notizen"
+
+#: sonar/modules/documents/templates/documents/record.html:91
+msgid "ISBN"
+msgstr "ISBN"
+
+#: sonar/modules/documents/templates/documents/record.html:97
+msgid "Permalink"
+msgstr "Permalink"
+
#: sonar/theme/templates/sonar/401.html:13
msgid "Unauthorized"
msgstr "Nicht autorisiert"
@@ -199,12 +231,12 @@ msgstr ""
#: sonar/theme/templates/sonar/accounts/forgot_password.html:28
#: sonar/theme/templates/sonar/accounts/login.html:16
-#: sonar/theme/templates/sonar/accounts/signup.html:44
+#: sonar/theme/templates/sonar/accounts/signup.html:49
msgid "Log In"
msgstr "Einloggen"
#: sonar/theme/templates/sonar/accounts/forgot_password.html:30
-#: sonar/theme/templates/sonar/accounts/login.html:34
+#: sonar/theme/templates/sonar/accounts/login.html:39
#: sonar/theme/templates/sonar/accounts/signup.html:28
#: sonar/theme/templates/sonar/oauth/signup.html:38
msgid "Sign Up"
@@ -215,11 +247,12 @@ msgid "Log in to account"
msgstr "Melden Sie sich bei Ihrem Konto an"
#: sonar/theme/templates/sonar/accounts/login.html:24
+#: sonar/theme/templates/sonar/accounts/login.html:30
#, python-format
msgid "Sign-in with %(type)s"
msgstr "Anmelden mit %(type)s"
-#: sonar/theme/templates/sonar/accounts/login.html:32
+#: sonar/theme/templates/sonar/accounts/login.html:37
msgid "Forgot password?"
msgstr "Passwort vergessen?"
@@ -229,6 +262,7 @@ msgid "Sign up for a %(sitename)s account"
msgstr "Melde dich für ein %(sitename)s-Konto an!"
#: sonar/theme/templates/sonar/accounts/signup.html:36
+#: sonar/theme/templates/sonar/accounts/signup.html:42
#: sonar/theme/templates/sonar/oauth/signup.html:25
#, python-format
msgid "Sign-up with %(type)s"
diff --git a/sonar/translations/fr/LC_MESSAGES/messages.po b/sonar/translations/fr/LC_MESSAGES/messages.po
index 0203c436..857d591a 100644
--- a/sonar/translations/fr/LC_MESSAGES/messages.po
+++ b/sonar/translations/fr/LC_MESSAGES/messages.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: sonar 0.0.1\n"
"Report-Msgid-Bugs-To: software@rero.ch\n"
-"POT-Creation-Date: 2019-07-22 13:54+0200\n"
+"POT-Creation-Date: 2019-07-22 16:12+0200\n"
"PO-Revision-Date: 2019-06-06 11:09+0200\n"
"Last-Translator: FULL NAME \n"
"Language: fr\n"
@@ -62,6 +62,38 @@ msgstr "Meilleure correspondance"
msgid "Most recent"
msgstr "Les plus récents"
+#: sonar/modules/documents/templates/documents/record.html:58
+msgid "Authors"
+msgstr "Auteurs"
+
+#: sonar/modules/documents/templates/documents/record.html:63
+msgid "Abstract"
+msgstr "Résumé"
+
+#: sonar/modules/documents/templates/documents/record.html:70
+msgid "Physical description"
+msgstr "Description"
+
+#: sonar/modules/documents/templates/documents/record.html:75
+msgid "Subject"
+msgstr "Sujet"
+
+#: sonar/modules/documents/templates/documents/record.html:80
+msgid "Language"
+msgstr "Langue"
+
+#: sonar/modules/documents/templates/documents/record.html:85
+msgid "Notes"
+msgstr "Notes"
+
+#: sonar/modules/documents/templates/documents/record.html:91
+msgid "ISBN"
+msgstr "ISBN"
+
+#: sonar/modules/documents/templates/documents/record.html:97
+msgid "Permalink"
+msgstr "Lien permanent"
+
#: sonar/theme/templates/sonar/401.html:13
msgid "Unauthorized"
msgstr "Non autorisé"
@@ -198,12 +230,12 @@ msgstr ""
#: sonar/theme/templates/sonar/accounts/forgot_password.html:28
#: sonar/theme/templates/sonar/accounts/login.html:16
-#: sonar/theme/templates/sonar/accounts/signup.html:44
+#: sonar/theme/templates/sonar/accounts/signup.html:49
msgid "Log In"
msgstr "Identification"
#: sonar/theme/templates/sonar/accounts/forgot_password.html:30
-#: sonar/theme/templates/sonar/accounts/login.html:34
+#: sonar/theme/templates/sonar/accounts/login.html:39
#: sonar/theme/templates/sonar/accounts/signup.html:28
#: sonar/theme/templates/sonar/oauth/signup.html:38
msgid "Sign Up"
@@ -214,11 +246,12 @@ msgid "Log in to account"
msgstr "Connectez-vous à votre compte"
#: sonar/theme/templates/sonar/accounts/login.html:24
+#: sonar/theme/templates/sonar/accounts/login.html:30
#, python-format
msgid "Sign-in with %(type)s"
msgstr "Se connecter avec %(type)s"
-#: sonar/theme/templates/sonar/accounts/login.html:32
+#: sonar/theme/templates/sonar/accounts/login.html:37
msgid "Forgot password?"
msgstr "Mot de passe oublié?"
@@ -228,6 +261,7 @@ msgid "Sign up for a %(sitename)s account"
msgstr "Inscrivez-vous sur %(sitename)s"
#: sonar/theme/templates/sonar/accounts/signup.html:36
+#: sonar/theme/templates/sonar/accounts/signup.html:42
#: sonar/theme/templates/sonar/oauth/signup.html:25
#, python-format
msgid "Sign-up with %(type)s"
diff --git a/sonar/translations/it/LC_MESSAGES/messages.po b/sonar/translations/it/LC_MESSAGES/messages.po
index f9e3c54f..1e20f7dd 100644
--- a/sonar/translations/it/LC_MESSAGES/messages.po
+++ b/sonar/translations/it/LC_MESSAGES/messages.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: sonar 0.0.1\n"
"Report-Msgid-Bugs-To: software@rero.ch\n"
-"POT-Creation-Date: 2019-07-22 13:54+0200\n"
+"POT-Creation-Date: 2019-07-22 16:12+0200\n"
"PO-Revision-Date: 2019-07-15 17:09+0200\n"
"Last-Translator: FULL NAME \n"
"Language: it\n"
@@ -62,6 +62,38 @@ msgstr "Migliori risultati"
msgid "Most recent"
msgstr "Più recenti"
+#: sonar/modules/documents/templates/documents/record.html:58
+msgid "Authors"
+msgstr "Autori"
+
+#: sonar/modules/documents/templates/documents/record.html:63
+msgid "Abstract"
+msgstr "Astratto"
+
+#: sonar/modules/documents/templates/documents/record.html:70
+msgid "Physical description"
+msgstr "Descrizione fisica"
+
+#: sonar/modules/documents/templates/documents/record.html:75
+msgid "Subject"
+msgstr "Soggetto"
+
+#: sonar/modules/documents/templates/documents/record.html:80
+msgid "Language"
+msgstr "Lingua"
+
+#: sonar/modules/documents/templates/documents/record.html:85
+msgid "Notes"
+msgstr "Note"
+
+#: sonar/modules/documents/templates/documents/record.html:91
+msgid "ISBN"
+msgstr "ISBN"
+
+#: sonar/modules/documents/templates/documents/record.html:97
+msgid "Permalink"
+msgstr "Collegamento permanente"
+
#: sonar/theme/templates/sonar/401.html:13
msgid "Unauthorized"
msgstr "Non autorizzato"
@@ -198,12 +230,12 @@ msgstr ""
#: sonar/theme/templates/sonar/accounts/forgot_password.html:28
#: sonar/theme/templates/sonar/accounts/login.html:16
-#: sonar/theme/templates/sonar/accounts/signup.html:44
+#: sonar/theme/templates/sonar/accounts/signup.html:49
msgid "Log In"
msgstr "Accedi"
#: sonar/theme/templates/sonar/accounts/forgot_password.html:30
-#: sonar/theme/templates/sonar/accounts/login.html:34
+#: sonar/theme/templates/sonar/accounts/login.html:39
#: sonar/theme/templates/sonar/accounts/signup.html:28
#: sonar/theme/templates/sonar/oauth/signup.html:38
msgid "Sign Up"
@@ -214,11 +246,12 @@ msgid "Log in to account"
msgstr "Accedi al tuo account"
#: sonar/theme/templates/sonar/accounts/login.html:24
+#: sonar/theme/templates/sonar/accounts/login.html:30
#, python-format
msgid "Sign-in with %(type)s"
msgstr ""
-#: sonar/theme/templates/sonar/accounts/login.html:32
+#: sonar/theme/templates/sonar/accounts/login.html:37
msgid "Forgot password?"
msgstr "Hai dimenticato la password?"
@@ -228,6 +261,7 @@ msgid "Sign up for a %(sitename)s account"
msgstr "Iscriviti per avere un account %(sitename)s!"
#: sonar/theme/templates/sonar/accounts/signup.html:36
+#: sonar/theme/templates/sonar/accounts/signup.html:42
#: sonar/theme/templates/sonar/oauth/signup.html:25
#, python-format
msgid "Sign-up with %(type)s"
diff --git a/sonar/translations/messages.pot b/sonar/translations/messages.pot
index 463e8542..0d3cba83 100644
--- a/sonar/translations/messages.pot
+++ b/sonar/translations/messages.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: sonar 0.0.1\n"
"Report-Msgid-Bugs-To: software@rero.ch\n"
-"POT-Creation-Date: 2019-07-22 13:54+0200\n"
+"POT-Creation-Date: 2019-07-22 16:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -61,6 +61,38 @@ msgstr ""
msgid "Most recent"
msgstr ""
+#: sonar/modules/documents/templates/documents/record.html:58
+msgid "Authors"
+msgstr ""
+
+#: sonar/modules/documents/templates/documents/record.html:63
+msgid "Abstract"
+msgstr ""
+
+#: sonar/modules/documents/templates/documents/record.html:70
+msgid "Physical description"
+msgstr ""
+
+#: sonar/modules/documents/templates/documents/record.html:75
+msgid "Subject"
+msgstr ""
+
+#: sonar/modules/documents/templates/documents/record.html:80
+msgid "Language"
+msgstr ""
+
+#: sonar/modules/documents/templates/documents/record.html:85
+msgid "Notes"
+msgstr ""
+
+#: sonar/modules/documents/templates/documents/record.html:91
+msgid "ISBN"
+msgstr ""
+
+#: sonar/modules/documents/templates/documents/record.html:97
+msgid "Permalink"
+msgstr ""
+
#: sonar/theme/templates/sonar/401.html:13
msgid "Unauthorized"
msgstr ""
@@ -192,12 +224,12 @@ msgstr ""
#: sonar/theme/templates/sonar/accounts/forgot_password.html:28
#: sonar/theme/templates/sonar/accounts/login.html:16
-#: sonar/theme/templates/sonar/accounts/signup.html:44
+#: sonar/theme/templates/sonar/accounts/signup.html:49
msgid "Log In"
msgstr ""
#: sonar/theme/templates/sonar/accounts/forgot_password.html:30
-#: sonar/theme/templates/sonar/accounts/login.html:34
+#: sonar/theme/templates/sonar/accounts/login.html:39
#: sonar/theme/templates/sonar/accounts/signup.html:28
#: sonar/theme/templates/sonar/oauth/signup.html:38
msgid "Sign Up"
@@ -208,11 +240,12 @@ msgid "Log in to account"
msgstr ""
#: sonar/theme/templates/sonar/accounts/login.html:24
+#: sonar/theme/templates/sonar/accounts/login.html:30
#, python-format
msgid "Sign-in with %(type)s"
msgstr ""
-#: sonar/theme/templates/sonar/accounts/login.html:32
+#: sonar/theme/templates/sonar/accounts/login.html:37
msgid "Forgot password?"
msgstr ""
@@ -222,6 +255,7 @@ msgid "Sign up for a %(sitename)s account"
msgstr ""
#: sonar/theme/templates/sonar/accounts/signup.html:36
+#: sonar/theme/templates/sonar/accounts/signup.html:42
#: sonar/theme/templates/sonar/oauth/signup.html:25
#, python-format
msgid "Sign-up with %(type)s"
diff --git a/tests/api/test_api_simple_flow.py b/tests/api/test_api_simple_flow.py
index 815a8590..a476c6aa 100644
--- a/tests/api/test_api_simple_flow.py
+++ b/tests/api/test_api_simple_flow.py
@@ -17,9 +17,11 @@ def test_simple_flow(client):
"""Test simple flow using REST API."""
headers = [('Content-Type', 'application/json')]
data = {
- 'title': 'The title of the record',
- 'abstracts': ['Record summary']
- }
+ 'title': 'The title of the record',
+ 'abstracts': [
+ {'language': 'fre', 'value': 'Record summary'}
+ ],
+ }
url = 'https://localhost:5000/documents/'
# create a record
diff --git a/tests/ui/documents/test_documents_views.py b/tests/ui/documents/test_documents_views.py
index 2e828b18..d4a564ca 100644
--- a/tests/ui/documents/test_documents_views.py
+++ b/tests/ui/documents/test_documents_views.py
@@ -41,3 +41,57 @@ def test_detail(app, client):
# assert isinstance(views.detail('1', record, ir='sonar'), str)
assert client.get('/organization/sonar/documents/1').status_code == 200
+
+
+def test_authors_format():
+ """Test author format filter."""
+ authors = [{'name': 'John Newby'}, {'name': 'Kevin Doner'}]
+
+ assert views.authors_format(authors) == 'John Newby ; Kevin Doner'
+
+
+def test_nl2br():
+ """Test nl2br conversion."""
+ text = 'Multiline text\nMultiline text'
+ assert views.nl2br(text) == 'Multiline text
Multiline text'
+
+
+def test_translate_content(app):
+ """Test content item translation."""
+ assert views.translate_content([], 'fr') is None
+
+ records = [{
+ 'language': 'eng',
+ 'value': 'Summary of content'
+ }, {
+ 'language': 'fre',
+ 'value': 'Résumé du contenu'
+ }]
+ assert views.translate_content(records, 'fr') == 'Résumé du contenu'
+ assert views.translate_content(records, 'de') == 'Summary of content'
+ assert views.translate_content(records, 'pt') == 'Summary of content'
+
+ with pytest.raises(Exception) as e:
+ views.translate_content(records, 'de', 'not_existing_key')
+ assert str(
+ e.value
+ ) == 'Value key "not_existing_key" in {record} does not exist'.format(
+ record=records[0])
+
+
+def test_get_code_from_bibliographic_language(app):
+ """Test bibliographic language code to alpha 2 code conversion."""
+ assert views.get_language_from_bibliographic_code('ger') == 'de'
+
+ with pytest.raises(Exception) as e:
+ views.get_language_from_bibliographic_code('zzz')
+ assert str(e.value) == 'Language code not found for "zzz"'
+
+
+def test_get_bibliographic_code_from_language(app):
+ """Test bibliographic language code to alpha 2 code conversion."""
+ with pytest.raises(Exception) as e:
+ views.get_bibliographic_code_from_language("zz")
+ assert str(e.value) == 'Language code not found for "zz"'
+
+ assert views.get_bibliographic_code_from_language('de') == 'ger'
diff --git a/tests/ui/documents/test_marc21tojson.py b/tests/ui/documents/test_marc21tojson.py
index b3be1adc..a5a669d7 100644
--- a/tests/ui/documents/test_marc21tojson.py
+++ b/tests/ui/documents/test_marc21tojson.py
@@ -182,7 +182,7 @@ def test_marc21_to_titlesProper():
assert data.get('titlesProper') == ['proper title', 'other proper title']
-def test_marc21_to_languages():
+def test_marc21_to_languages(app):
"""Test dojson marc21languages."""
marc21xml = """
@@ -198,7 +198,13 @@ def test_marc21_to_languages():
"""
marc21json = create_record(marc21xml)
data = marc21tojson.do(marc21json)
- assert data.get('languages') == [{'language': 'ara'}, {'language': 'eng'}]
+ assert data.get('languages') == [{
+ 'code': 'ara',
+ 'name': 'العربية'
+ }, {
+ 'code': 'eng',
+ 'name': 'English'
+ }]
assert data.get('translatedFrom') == ['ita']
marc21xml = """
@@ -216,11 +222,16 @@ def test_marc21_to_languages():
"""
marc21json = create_record(marc21xml)
data = marc21tojson.do(marc21json)
- assert data.get('languages') == [
- {'language': 'ara'},
- {'language': 'eng'},
- {'language': 'fre'}
- ]
+ assert data.get('languages') == [{
+ 'code': 'ara',
+ 'name': 'العربية'
+ }, {
+ 'code': 'eng',
+ 'name': 'English'
+ }, {
+ 'code': 'fre',
+ 'name': 'Français'
+ }]
assert data.get('translatedFrom') == ['ita', 'ger']
marc21xml = """
@@ -235,7 +246,13 @@ def test_marc21_to_languages():
"""
marc21json = create_record(marc21xml)
data = marc21tojson.do(marc21json)
- assert data.get('languages') == [{'language': 'ara'}, {'language': 'eng'}]
+ assert data.get('languages') == [{
+ 'code': 'ara',
+ 'name': 'العربية'
+ }, {
+ 'code': 'eng',
+ 'name': 'English'
+ }]
assert 'translatedFrom' not in data
@@ -470,13 +487,17 @@ def test_marc21_to_abstract():
marc21xml = """
+ eng
This book is about
"""
marc21json = create_record(marc21xml)
data = marc21tojson.do(marc21json)
- assert data.get('abstracts') == ["This book is about"]
+ assert data.get('abstracts') == [{
+ 'language': 'eng',
+ 'value': 'This book is about'
+ }]
def test_marc21_to_identifiers():
@@ -549,14 +570,22 @@ def test_marc21_to_subjects():
marc21xml = """
-
+
+ eng
subject 1 ; subject 2
+
+ fre
+ sujet 1 ; sujet 2
+
"""
marc21json = create_record(marc21xml)
data = marc21tojson.do(marc21json)
- assert data.get('subjects') == ['subject 1', 'subject 2']
+ assert data.get('subjects') == [
+ {'language': 'eng', 'value': ['subject 1', 'subject 2']},
+ {'language': 'fre', 'value': ['sujet 1', 'sujet 2']},
+ ]
def test_marc21_to_pid():